Problem:
Score : 700 points

Problem Statement

There are N panels arranged in a row in Takahashi's house, numbered 1 through N. The i-th panel has a number A_i written on it. Takahashi is playing by throwing balls at these panels.

Takahashi threw a ball K times. Let the panel hit by a boll in the i-th throw be panel p_i. He set the score for the i-th throw as i \times A_{p_i}.

He was about to calculate the total score for his throws, when he realized that he forgot the panels hit by balls, p_1,p_2,...,p_K. The only fact he remembers is that for every i (1 ≦ i ≦ K-1), 1 ≦ p_{i+1}-p_i ≦ M holds. Based on this fact, find the maximum possible total score for his throws.

Constraints

1 ≦ M ≦ N ≦ 100,000

1 ≦ K ≦ min(300,N)

1 ≦ A_i ≦ 10^{9}

Partial Scores

In the test set worth 100 points, M = N.

In the test set worth another 200 points, N ≦ 300 and K ≦ 30.

In the test set worth another 300 points, K ≦ 30.

Input

The input is given from Standard Input in the following format:

N M K
A_1 A_2 … A_N

Output

Print the maximum possible total score for Takahashi's throws.

Sample Input 1

5 2 3
10 2 8 10 2

Sample Output 1

56

The total score is maximized when panels 1,3 and 4 are hit, in this order.

Sample Input 2

5 5 2
5 2 10 5 9

Sample Output 2

28

This case satisfies the additional constraint M = N for a partial score.

Sample Input 3

10 3 5
3 7 2 6 9 4 8 5 1 1000000000

Sample Output 3

5000000078

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

template <typename T> vector<T> sliding_maximum(const vector<T> &a, int k){
  int n = a.size();
  deque<int> dq;
  vector<T> ret;

  REP(i,k){
    while(not dq.empty() and a[dq.back()] <= a[i]){
      dq.pop_back();
    }

    dq.push_back(i);
  }

  REP(i,n-k+1){
    while(dq.front() < i){
      dq.pop_front();
    }

    ret.push_back(a[dq.front()]);

    while(not dq.empty() and i+k < n and a[dq.back()] <= a[i+k]){
      dq.pop_back();
    }
    
    dq.push_back(i+k);
  }
  
  return ret;
}


LLI dp[310][101000];
const LLI ninf = -(1LL<<40);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  LLI n,m,k;
  while(cin >> n >> m >> k){
    vector<LLI> A(n); cin >> A;

    fill_array(dp, ninf);

    REP(i,n){
      dp[1][i] = A[i];
    }

    FORE(j,2,k){
      
      vector<LLI> temp(dp[j-1], dp[j-1]+n);

      vector<LLI> b(n);

      {
        LLI t = ninf;
        REP(i,m){
          b[i] = t;
          t = max(t,dp[j-1][i]);
        }

        auto s = sliding_maximum(temp,m);

        FOR(i,m,n){
          b[i] = s[i-m];
        }
      }
      
      REP(i,n){
        if(b[i] >= 0) dp[j][i] = b[i] + A[i] * j;
      }      
    }

    LLI ans = 0;
    FOR(i,k,n) chmax(ans, dp[k][i]);

    cout << ans << endl;
    
  }
  
  return 0;
}