#include <bits/stdc++.h>
using namespace std;
const int maxx = 100000 + 5;
const int maxn = 300000 + 7;
const long long mod = 998244353;
const int maxs = 5 * (1E5) + 7;
const int maxm = 30000 + 7;
const int maxw = 100 + 7;
const int maxh = 100 + 7;
const double inf = 1e18 + 7;
const long long ten = 10;
ostream &operator<<(ostream &os, pair<long long, long long> &rhs) {
  os << rhs.first << " " << rhs.second << endl;
  return os;
}
long long dp[maxn];
long long sum[maxn];
long long seq[maxn];
long long n, k, m;
void init() {
  for (long long i = (1); i <= (n); i++) {
    scanf("%lld", &seq[i]);
    dp[i] = -inf;
  }
  dp[0] = -inf;
}
void solve() {
  for (long long rv = (1); rv <= (n); rv++) {
    long long &ans = dp[rv];
    long long lv;
    long long ss = 0;
    long long as = -inf;
    for (lv = rv; (lv >= 1 && lv >= rv - m + 1); lv--) {
      ss += seq[lv];
      as = max(ss, as);
    }
    as -= k;
    ans = as;
    if (rv < m) continue;
    ans = max(ans, ss + dp[rv - m] - k);
  }
  long long ans = 0;
  for (long long i = (1); i <= (n); i++) {
    ans = max(ans, dp[i]);
  }
  printf("%lld\n", ans);
}
int main(void) {
  while (scanf("%lld%lld%lld", &n, &m, &k) == 3) {
    init();
    solve();
  }
  return 0;
}
