#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
//#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 1e4+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 1e5+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
//#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 5e3+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 1e3+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 5e3+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(dp[in][k]!=-1) return dp[in][k];
  if(k==0) return 0;
  if(in>n) return 0;
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 1e4+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 5e3+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>=n) return -1;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  pr[0]=0;
  memset(dp,-1,sizeof dp);
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bitset>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
typedef long long int ll;
#define int long long int
typedef pair <int,int> ii ;
typedef vector < int > vi ;
typedef vector < ii > vii ;
#define rep(i,n)                   for(int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++)
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define fi first
#define se second
#define all(p)                p.begin(),p.end()
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Endl endl
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (int)r;}
template <class T>inline void sary(T st, T nd){while(st<nd)cin>>*st++;/*sf("%d", st++);*/}
const int mod=1e9+7;
inline ll mul(ll a, ll b){return ((a%mod)*(b%mod))%mod;}
inline ll add(ll a, ll b){return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a, ll b){return ((a%mod)-(b%mod)+mod)%mod;}
const int N= 5e3+1;

int pr[N], dp[N][N];
int n;

int solve(int in, int m, int k) {
  if(k==0) return 0;
  if(in>n) return 0;
  if(dp[in][k]!=-1) return dp[in][k];
  int mx=0;
  mx=solve(in+1,m,k);
  if(in+m-1<=n) mx=max(mx,pr[in+m-1]-pr[in-1]+solve(in+m,m,k-1));
  return dp[in][k]=mx;
}

void calc() {
  int m,k; cin>>n>>m>>k;
  memset(dp,-1,sizeof dp);
  pr[0]=0;
  rep(i,n) {
    int x; cin>>x;
    pr[i+1]=pr[i]+x;
  }
  cout<<solve(1,m,k);
}

int32_t main() {
  IOS
  int t;
  t=1;
  //cin>>t;
  while(t--) calc();
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (i -1 >= 0 && j-1 >= 0 && i-m >= 0) dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m+1][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (i-m < 0)
                {
                    dp[i][j] = dp[i-1][j];
                }
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
                }

            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (i-m >= 0) dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }
    memset(arr, -1, sizeof(arr));

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;
    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    ll maximo = 0;
    for(int i = 0; i < k; ++i)
    {
        ll mejor = -1;
        int posMejor = -1;
        for(int z = 0; z < n; ++z)
        {
            if (mejor < arr[z])
            {
                posMejor = z;
                mejor = arr[z];
            }
        }
        int tam = 0;
        for(int li = posMejor; li >= 0 && tam < m; --li)
        {
            arr[li] = 0;
            tam++;
        }
        maximo += mejor;
        //cout << maximo << endl;
    }

    cout << maximo << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1 || i == 0)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (i -1 >= 0 && j-1 >= 0) dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }
    memset(arr, -1, sizeof(arr));

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                if (i-m < 0 && i - 1 >= 0)
                {
                    // cout << i-1 << endl;
                    dp[i][j] = dp[i-1][j];
                }
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
                }

            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll sums[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }
    memset(sums, -1, sizeof(sums));

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    sums[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        sums[i] = sums[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else if (i == m-1)
            {
                dp[i][j] = sums[i];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + sums[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;

}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }
    memset(arr, -1, sizeof(arr));

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>

#include <unordered_map>
#include <unordered_set>
using namespace std;

//string s;
//getline(cin, s);

typedef long long ll; // comments that are mixed in with code
typedef pair<int, int> pii;
typedef unsigned long ull; // are aligned to the right like this
typedef vector<pii> vii;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef priority_queue<int> maxPq;
typedef priority_queue<ll, vector<ll>, greater<ll> > minPq;
typedef deque<int> dq;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forVar(type, var, init, till, increment) for (type var = init; var < till; var += increment)
#define deb(x) cout << x << endl;
#define MAX 5 * 10000 + 1
#define INF 10000000000
#define endl '\n'

ll arr[5010];
ll nums[5010];
ll dp[5010][5010];
int n, m, k;
ll curr;

int main()
{
    cin >> n >> m >> k;

    for (int i = 0; i < n; ++i)
    {
        cin >> curr;
        nums[i] = curr;
    }
    memset(arr, -1, sizeof(arr));

    ll ini = 0;
    for(int i = 0; i < m; ++i)
    {
        ini += nums[i];
    }

    arr[m-1] = ini;

    int j = 0;

    for(int i = m; i < n; ++i)
    {
        arr[i] = arr[i-1] - nums[j] + nums[i];
        ++j;
    }

    ll best = -1;

    for(int i = 0; i < n; ++i)
    {
        for(j = 0; j <= k; ++j)
        {
            if (j == 0 || i < m-1)
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i-m][j-1] + arr[i]);
            }
        }
    }

    cout << dp[n-1][k] << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	for(int i=1;i<m;++i){
		vs.push_back(0);
	}
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n-1][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=m;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	ll sum=0;

	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}

	//sum=accumulate(vp+1,vp+m+1,0);
	vs[m]=sum;
	if(n==3510)
		cout<<sum<<endl;
	for(int i=m+1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));

	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	for(int i=1;i<m;++i){
		vs.push_back(0);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=max(dp[i-1][j],vs[i-1]);;
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i-1]);
			}
			cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;

	cout<<dp[n-1][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5010];
ll vs[5010];
ll dp[5010][5010];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	vs[m]=(accumulate(vp+1,vp+m+1,0));
	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		vs[i]=vs[i-1]-vp[i-m]+vp[i];
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));
	ll sum=0;
	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}
	vs[m]=sum;
	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	vs[m]=(accumulate(vp+1,vp+m+1,0LL));
	ll sum=vs[m];
	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+1,vector<ll>(k+1,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
		dp[i][1]=vs[i];
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=0;i<=n-m;++i){
		for(int j=1;j<=k;++j){
			if(i>0)
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n-m][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+1,vector<ll>(k+1,-1));
	for(int i=0;i<n;++i){
		dp[i][0]=0;
	}
	for(int i=0;i<=n-m;++i){
		for(int j=1;j<=k;++j){
			if(i>0)
				dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
				//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
			}
		}
	}
	for(auto& i:vs){
		//cout<<i<<" ";
	}
	cout<<endl;
	cout<<dp[n-m][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	for(int i=0;i<m;++i){
		vs.push_back(0);
	}
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));
	ll sum=0;
	for(int i=1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum+=vp[i];
		if(i>=m){
			vs[i]=sum;
			sum-=vp[i-m+1];
		}
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=m;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	ll sum=0;
/*
	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}
*/
	sum=accumulate(vp+1,vp+m+1,0LL);
	vs[m]=sum;
/*
	if(n==3510)
		cout<<sum<<endl;
*/
	for(int i=m+1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));

	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	vs[m]=(accumulate(vp+1,vp+m+1,0));
	ll sum=vs[m];
	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=m;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	ll sum=0;
/*
	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}
*/
	sum=accumulate(vp+1,vp+m+1,0);
	vs[m]=sum;
	if(n==3510)
		cout<<sum<<endl;
	for(int i=m+1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));

	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE  freopen("D.in","r",stdin)
#define WE  freopen("1biao.out","w",stdout)
#define mp make_pair
#define pb push_back
const double eps=1e-10;
const double pi=acos(-1.0);
int a[5111];
ll sum[5111];
ll f[5111][5111];///f[i][j],到i时选了j个区间
int n,m,k;
int main(){
    int i,j;
    RD3(n,m,k);
    FOR(i,1,n){
        RD(a[i]);
    }
    ll sm=0;
    FOR(i,1,n){
        sm+=a[i];
        if(i>=m){
            sum[i]=sm;
            sm-=a[i-m+1];
        }
    }
    mf1(f);///全部置为-1
    FOR(i,0,n) f[i][0]=0;
    FOR(i,1,n){
        FOR(j,1,k){
            f[i][j]=f[i-1][j];
            if(i-m>=0 && f[i-m][j-1] != -1) f[i][j]=max(f[i][j],f[i-m][j-1]+sum[i]);
        }
    }
    printf("%I64d\n",f[n][k]);
    return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=m;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	ll sum=0;
/*
	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}
*/
	sum=accumulate(vp+1,vp+m+1,0LL);
	vs[m]=sum;
	if(n==3510)
		cout<<sum<<endl;
	for(int i=m+1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));

	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0LL));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+1,vector<ll>(k+1,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
		dp[i][1]=vs[i];
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=0;i<=n-m;++i){
		for(int j=1;j<=k;++j){
			if(i>0)
				dp[i][j]=max(dp[i][j],dp[i-1][j]);
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n-m][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	for(int i=0;i<m;++i){
		vs.push_back(0);
	}
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
ll vp[5210];
ll vs[5210];
ll dp[5210][5210];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	//vector<ll> vp;
	for(int i=1;i<=n;++i){
		//ll t;
		//cin>>t;
		//vp.push_back(t);
		cin>>vp[i];
	}
	//vector<ll> vs;
	//for(int i=0;i<m;++i){
		//vs.push_back(0);
	//}
	//vs[m]=(accumulate(vp+1,vp+m+1,0));
	ll sum=0;
/*
	for(int i=1;i<=m;++i){
		sum+=vp[i];
	}
*/
	sum=accumulate(vp+1,vp+m+1,0);
	vs[m]=sum;
	for(int i=m+1;i<=n;++i){
		//vs.push_back(vs.back()-vp[i-m]+vp[i]);
		sum-=vp[i-m];
		sum+=vp[i];
		vs[i]=sum;
	}
	//vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	for(int i=1;i<m;++i){
		vs.push_back(0);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=max(dp[i-1][j],vs[i-1]);;
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i-1]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n-1][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	for(int i=0;i<m;++i){
		vs.push_back(0);
	}
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;

	cout<<dp[n-1][k]<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	vector<ll> vp;
	for(int i=1;i<=n;++i){
		ll t;
		cin>>t;
		vp.push_back(t);
	}
	vector<ll> vs;
	for(int i=0;i<m;++i){
		vs.push_back(0);
	}
	vs.push_back(accumulate(vp.begin(),vp.begin()+m,0));
	for(int i=m;i<(int)vp.size();++i){
		vs.push_back(vs.back()-vp[i-m]+vp[i]);
	}
	vector<vector<ll>> dp(n+10,vector<ll>(k+10,-1));
	for(int i=0;i<=n-m;++i){
		dp[i][0]=0;
	}
	//cout<<dp[0][0]<<"\n";
	for(int i=1;i<=n;++i){
		for(int j=1;j<=k;++j){
			dp[i][j]=dp[i-1][j];
			if(i-m>=0&&dp[i-m][j-1]!=-1){
				//cout<<"#"<<vs[i]<<endl;
				dp[i][j]=max(dp[i][j],dp[i-m][j-1]+vs[i]);
			}
			//cout<<"dp["<<i<<"]["<<j<<"]="<<dp[i][j]<<"\n";
		}
	}
/*	for(auto& i:vs){
		cout<<i<<" ";
	}
	cout<<endl;
*/
	cout<<dp[n-1][k]<<endl;
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll dp[N]={0};
ll dp2[N][N];
ll a[N]={0};
int n,m,k;

ll Solve_2(int id,int k1)
{
	if(id>n || k1>k)
	{
		dp2[id][k1]=0;
		return dp2[id][k1];
	}
	if(dp2[id][k1]!=-1) return dp2[id][k1];
	ll ans=0;

	f(i,id,n)
	{
		ans=max(ans,dp[i]+Solve_2(i+m,k1+1));
	}
	dp2[id][k1]=ans;
	return dp2[id][k1];
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	nf(i,m,n)
	{
		dp[i]=dp[i]-dp[i-m];
	}
	memset(dp2,-1,sizeof(dp2));
	ll ans = Solve_2(m,1);
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll pre[N]={0};
ll dp[N][N];
ll n,m,k;

ll Solve_2(ll id,ll k1)
{
	if(k1==0) return 0;
	if(id<1 || k1<0) return -1e18;
	if(dp[id][k1]!=-1) return dp[id][k1];
	ll ans= Solve_2(id-1,k1);
	if(id-m>=0)
	{
		ans= max(ans, Solve_2(id-m,k-1)+pre[id]-pre[id-m]);
	}
	return dp[id][k1]=ans;
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>pre[i];
		pre[i] += pre[i-1];
	}
	memset(dp,-1,sizeof(dp));
	ll ans= Solve_2(n,k);
	cout<<ans;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll dp[N]={0};
ll dp2[N][N];
ll a[N]={0};
int n,m,k;

ll Solve_2(int id,int k1)
{
	if(id>n || k1>k) return 0;
	if(dp2[id][k1]!=-1) return dp2[id][k1];
	ll ans=0;

	f(i,id,n)
	{
		ans=max(ans,dp[i]+Solve_2(i+m,k1+1));
	}
	dp2[id][k1]=ans;
	return dp2[id][k1];
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	nf(i,m,n)
	{
		dp[i]=dp[i]-dp[i-m];
	}
	memset(dp2,-1,sizeof(dp2));
	ll ans = Solve_2(m,1);
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

void Solve()
{
	ll n,m,k;
	cin>>n>>m>>k;

	v(ll) a(n);
	fe(x,a) cin>>x;

	ll ans=0;
	while(k--)
	{
		v(ll) pre;
		ll  tmp=0;
		fe(x,a)
		{
			tmp +=x;
			pre.pub(tmp);
		}
		int id=0;
		ll zep=pre[m-1];
		int n1=pre.sz;

		f(i,m,n1-1)
		{
			if(zep<pre[i]-pre[i-m])
			{
				id=i-m+1;
				zep=pre[i]-pre[i-m];
			}
		}
		ans += zep;
		a.erase(a.B+id,a.B+id+m);
	}
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll pre[N]={0};
ll dp[N][N];
ll n,m,k;

ll fun(int id,int k1)
{
	if(k1<0) return -1e18;
	if(id>n)
	{
		if(k1==0) return 0;
		return -1e18;
	}
	ll &ans= dp[id][k1];
	if(ans!=-1) return ans;

	ans=pre[id]-pre[id-m]+fun(id+m,k1-1);
	ans=max(ans,fun(id+1,k1));
	return ans;
}

void Solve()
{
	cin>>n>>m>>k;
	memset(dp,-1,sizeof(dp));
	f(i,1,n)
	{
		cin>>pre[i];
		pre[i]+=pre[i-1];
	}

	cout<< fun(m,k);
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll dp[N]={0};
ll dp2[N][N];
ll a[N]={0};
int n,m,k;

ll Solve_2(int id,int k1)
{
	if(id>n || k1>k)
	{
		dp2[id][k1]=0;
		return dp2[id][k1];
	}
	if(dp2[id][k1]!=-1) return dp2[id][k1];
	ll ans=0;

	f(i,id,n)
	{
		ans=max(ans,dp[i]+Solve_2(i+m,k1+1));
	}
	dp2[id][k1]=ans;
	return dp2[id][k1];
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	nf(i,m,n)
	{
		dp[i]=dp[i]-dp[i-m];
	}

	if(m*k ==n)
	{
		ll sum=0;
		f(i,1,n) sum += a[i];
		cout<<sum;
		return;
	}

	memset(dp2,-1,sizeof(dp2));
	ll ans = Solve_2(m,1);
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll dp[N]={0};
ll dp2[N][N];
ll a[N]={0};
ll n,m,k;

ll Solve_2(ll id,ll k1)
{
	if(id>n || k1>k)
	{
		dp2[id][k1]=0;
		return dp2[id][k1];
	}
	if(dp2[id][k1]!=-1) return dp2[id][k1];
	ll ans=0;

	f(i,id,n)
	{
		ans=max(ans,dp[i]+Solve_2(i+m,k1+1));
	}
	dp2[id][k1]=ans;
	return dp2[id][k1];
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	nf(i,m,n)
	{
		dp[i]=dp[i]-dp[i-m];
	}

	if(m*k ==n)
	{
		ll sum=0;
		f(i,1,n) sum += a[i];
		cout<<sum;
		return;
	}

	memset(dp2,-1,sizeof(dp2));
	ll ans = Solve_2(m,1);
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll pre[N]={0};
ll dp[N][N];
ll a[N]={0};
ll n,m,k;

ll Solve_2(ll id,ll k1)
{
	if(id>n) return 0;
	if(dp[id][k1]!=-1) return dp[id][k1];

	ll ans= Solve_2(id+1,k1);
	if(k1>0)
	{
		ll right= min(n,id+m-1);
		ans=max(ans,pre[right]-pre[id-1]+Solve_2(right+1,k1-1));
	}
}

void Solve()
{
	cin>>n>>m>>k;
	memset(dp,-1,sizeof(dp));
	f(i,1,n)
	{
		cin>>a[i];
		pre[i]=pre[i-1]+a[i];
	}
	cout<< Solve_2(1,k);
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


/*
   AUTHOR :- Gaurang_Kothiya

   Quote:-" Great things never come from comfort zones."
*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set;
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ld long double
#define f(i,x,n) for(auto i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(auto i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map
#define u_m(a,b) unordered_map
#define mm(a,b) multimap
#define s(a) set
#define us(a) unordered_set
#define ms(a) multiset
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

const int N=5005;
ll dp[N]={0};
ll a[N]={0};
int n,m,k;

ll Solve_2(int id,int k1)
{
	if(id>n || k1>k) return 0;

	ll ans=0;

	f(i,id,n)
	{
		ans=max(ans,dp[i]+Solve_2(i+m,k1+1));
	}
	return ans;
}

void Solve()
{
	cin>>n>>m>>k;
	f(i,1,n)
	{
		cin>>a[i];
		dp[i]=a[i]+dp[i-1];
	}
	nf(i,m,n)
	{
		dp[i]=dp[i]-dp[i-m];
	}
	ll ans = Solve_2(m,1);
	cout<< ans ;
}

signed main()
{
	speed

	int q=1;
	//cin>>q;

	while(q--)
	Solve();

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


// (c) 2019, redotter
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y0998244353
#define y1 y1998244353
#define die(cond) if (cond) for (;;) {}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max();
const ld eps = 1e-9;
const ld pi = acosl(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

void solve(), read();

signed main() {
	fast;
	read();
	solve();
	return 0;
}

struct fast_io {
	inline char read_char() {
		char c = _getchar_nolock();
		while (c <= 32) {
			c = _getchar_nolock();
		}
		return c;
	}
	inline ll read_int() {
		ll ans = 0;
		char c = _getchar_nolock();
		while (c <= 32) {
			c = _getchar_nolock();
		}
		bool sign = 0;
		if (c == '-') {
			sign = 1;
			c = _getchar_nolock();
		}
		while ('0' <= c && c <= '9') {
			ans = (ans << 3) + (ans << 1) + (c - '0');
			c = _getchar_nolock();
		}
		if (sign) {
			ans = -ans;
		}
		return ans;
	}
	inline string read_string(bool full = 0) {
		string ans = "";
		char c = _getchar_nolock();
		while (c == 32) {
			c = _getchar_nolock();
		}
		while (full ? (c != '\n') : (c > 32)) {
			ans.pb(c);
			c = _getchar_nolock();
		}
		return ans;
	}
	inline void write_string(string s) {
		for (char c : s) {
			_putchar_nolock(c);
		}
	}
	inline void write_int(ll x) {
		write_string(to_string(x));
	}
	inline void write_char(char c) {
		_putchar_nolock(c);
	}
} io;

const ll MAXN = 250000 + 10;
const ll MAXM = 1e7 + 10;
int n, m, q;
vector<pair<int, int>> ks[MAXN];
pair<int, ll> a[MAXM];
vector<int> lft, rgh;
vll dp;

void count_lft() {
	lft.resize(m + 1, 0);
	vector<int> st;
	for (int i = 1; i <= m; i++) {
		lft[i] = i;
		while (!st.empty() && i - st.back() < a[i].ft) {
			mineq(lft[i], lft[st.back()]);
			st.popb();
		}
		st.pb(i);
	}
}
void count_rgh() {
	rgh.resize(m + 1, 0);
	vector<int> st;
	for (int i = m; i >= 1; i--) {
		rgh[i] = i;
		while (!st.empty() && st.back() - i < a[i].ft) {
			maxeq(rgh[i], rgh[st.back()]);
			st.popb();
		}
		st.pb(i);
	}
}
void count_dp() {
	dp.resize(m + 1, inf);
	dp[0] = 0;
	vector<int> st;
	st.pb(0);
	for (int i = 1; i <= m; i++) {
		mineq(dp[rgh[i]], dp[i - 1] + ll(a[i].sd));
		for (int j = sz(st) - 1; j >= 0; j--) {
			if (st[j] + 1 < lft[i]) {
				st.resize(min(sz(st), ll(j) + 2));
				break;
			}
			mineq(dp[i], dp[st[j]] + ll(a[i].sd));
		}
		for (int j = sz(st) - 1; j >= 0; j--) {
			if (dp[st[j]] > dp[i]) {
				st.popb();
			} else {
				break;
			}
		}
		st.push_back(i);
	}
}

void solve() {
	count_lft();
	count_rgh();
	count_dp();
	io.write_int(dp[m]);
}

void read() {
	n = io.read_int();
	m = io.read_int();
	for (int i = 0; i < n; i++) {
		int k;
		k = io.read_int();
		ks[i].resize(k);
		for (int j = 0; j < k; j++) {
			ks[i][j].ft = io.read_int();
		}
		for (int j = 0; j < k; j++) {
			ks[i][j].sd = io.read_int();
		}
	}
	q = io.read_int();
	ll j = 1;
	for (int i = 0; i < q; i++) {
		int id, mul;
		id = io.read_int();
		mul = io.read_int();
		--id;
		for (pair<int, ll> p : ks[id]) {
			a[j++] = { p.ft, p.sd * mul };
		}
	}
}


// (c) 2019, redotter
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y0998244353
#define y1 y1998244353
#define die(cond) if (cond) for (;;) {}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max();
const ld eps = 1e-9;
const ld pi = acosl(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

void solve(), read();

signed main() {
	fast;
	read();
	solve();
	return 0;
}

struct fast_io {
	inline char read_char() {
		char c = _getchar_nolock();
		while (c <= 32) {
			c = _getchar_nolock();
		}
		return c;
	}
	inline int read_int() {
		int ans = 0;
		char c = _getchar_nolock();
		while (c <= 32) {
			c = _getchar_nolock();
		}
		bool sign = 0;
		if (c == '-') {
			sign = 1;
			c = _getchar_nolock();
		}
		while ('0' <= c && c <= '9') {
			ans = (ans << 3) + (ans << 1) + (c - '0');
			c = _getchar_nolock();
		}
		if (sign) {
			ans = -ans;
		}
		return ans;
	}
	inline string read_string(bool full = 0) {
		string ans = "";
		char c = _getchar_nolock();
		while (c == 32) {
			c = _getchar_nolock();
		}
		while (full ? (c != '\n') : (c > 32)) {
			ans.pb(c);
			c = _getchar_nolock();
		}
		return ans;
	}
	inline void write_string(string s) {
		for (char c : s) {
			_putchar_nolock(c);
		}
	}
	inline void write_int(ll x) {
		write_string(to_string(x));
	}
	inline void write_char(char c) {
		_putchar_nolock(c);
	}
} io;

const ll MAXN = 250000 + 10;
const ll MAXM = 1e7 + 10;
int n, m, q;
vector<int> h1[MAXN];
vector<int> c1[MAXN];
int lft[MAXM], rgh[MAXM];
ll dp[MAXM];
int hs[MAXM];
ll cost[MAXM];

void count_lft() {
	vector<int> st;
	for (int i = 1; i <= m; i++) {
		lft[i] = i;
		while (!st.empty() && i - st.back() < hs[i]) {
			mineq(lft[i], lft[st.back()]);
			st.popb();
		}
		st.pb(i);
	}
}
void count_rgh() {
	vector<int> st;
	for (int i = m; i >= 1; i--) {
		rgh[i] = i;
		while (!st.empty() && st.back() - i < hs[i]) {
			maxeq(rgh[i], rgh[st.back()]);
			st.popb();
		}
		st.pb(i);
	}
}
void count_dp() {
	for (ll i = 0; i <= m; i++) {
		dp[i] = inf;
	}
	dp[0] = 0;
	vector<int> st;
	st.pb(0);
	for (int i = 1; i <= m; i++) {
		mineq(dp[rgh[i]], dp[i - 1] + cost[i]);
		for (int j = sz(st) - 1; j >= 0; j--) {
			if (st[j] + 1 < lft[i]) {
				st.resize(min(sz(st), ll(j) + 2));
				break;
			}
			mineq(dp[i], dp[st[j]] + cost[i]);
		}
		for (int j = sz(st) - 1; j >= 0; j--) {
			if (dp[st[j]] > dp[i]) {
				st.popb();
			} else {
				break;
			}
		}
		st.push_back(i);
	}
}

void solve() {
	count_lft();
	count_rgh();
	count_dp();
	io.write_int(dp[m]);
}

void read() {
	n = io.read_int();
	m = io.read_int();
	for (int i = 0; i < n; i++) {
		int k;
		k = io.read_int();
		h1[i].resize(k);
		c1[i].resize(k);
		for (int j = 0; j < k; j++) {
			h1[i][j] = io.read_int();
		}
		for (int j = 0; j < k; j++) {
			c1[i][j] = io.read_int();
		}
	}
	q = io.read_int();
	ll j = 1;
	for (int i = 0; i < q; i++) {
		int id, mul;
		id = io.read_int();
		mul = io.read_int();
		--id;
		for (int d = 0; d < sz(h1[id]); d++) {
			hs[j] = h1[id][d];
			cost[j] = c1[id][d] * 1ll * mul;
			++j;
		}
	}
}


// (c) 2019, redotter
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y0998244353
#define y1 y1998244353
#define die(cond) if (cond) for (;;) {}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acosl(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

void solve(), read();

signed main() {
	fast;
	read();
	solve();
5	return 0;
}

ll n, m, q;
vector<vector<pll>> ks;
vector<pll> a;
vll lft, rgh;
vll dp;

void count_lft() {
	lft.resize(m + 1);
	stack<ll, vll> st;
	for (ll i = 1; i <= m; i++) {
		lft[i] = i;
		while (!st.empty() && i - st.top() < a[i].ft) {
			mineq(lft[i], lft[st.top()]);
			st.pop();
		}
		st.push(i);
	}
}
void count_rgh() {
	rgh.resize(m + 1);
	stack<ll, vll> st;
	for (ll i = m; i >= 1; i--) {
		rgh[i] = i;
		while (!st.empty() && st.top() - i < a[i].ft) {
			maxeq(rgh[i], rgh[st.top()]);
			st.pop();
		}
		st.push(i);
	}
}
void count_dp() {
	dp.resize(m + 1, inf);
	dp[0] = 0;
	for (ll i = 1; i <= m; i++) {
		for (ll j = lft[i] - 1; j < i; j++) {
			mineq(dp[i], dp[j] + a[i].sd);
		}
		mineq(dp[rgh[i]], dp[i - 1] + a[i].sd);
	}
}

void solve() {
	count_lft();
	count_rgh();
	count_dp();
	cout << dp[m] << endl;
}

void read() {
	cin >> n >> m;
	ks.resize(n);
	for (ll i = 0; i < n; i++) {
		ll k;
		cin >> k;
		ks[i].resize(k);
		for (ll j = 0; j < k; j++) {
			cin >> ks[i][j].ft;
		}
		for (ll j = 0; j < k; j++) {
			cin >> ks[i][j].sd;
		}
	}
	cin >> q;
	a.pb({ 0, 0 });
	for (ll i = 0; i < q; i++) {
		ll id, mul;
		cin >> id >> mul;
		--id;
		for (pll p : ks[id]) {
			a.pb({ p.ft, p.sd * mul });
		}
	}
}