#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005, maxm = 15;
const long long INF = 0x7FFFFFFFFFFFFFFF;
int n, m, k, a[maxn];
long long ans, sum[maxn], val[maxm];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i];
  for (int i = 1; i < m; i++) val[i] = INF;
  for (int i = 1; i <= n; i++) {
    if (i % m)
      val[i % m - 1] += k;
    else
      val[m - 1] += k;
    long long res = val[0];
    for (int j = 1; j < m; j++) res = min(res, val[j]);
    ans = max(ans, sum[i] - res);
    val[i % m] = min(val[i % m], sum[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
