#include <bits/stdc++.h>
using namespace std;
const int prime = 999983;
const int INF = 0x7FFFFFFF;
const long long INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long s = 1;
  while (b > 0) {
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
long long n, m, k;
const int maxn = 3e5 + 10;
long long a[maxn];
long long dp[maxn][12];
long long t[maxn];
long long sum[maxn];
long long F(long long n, long long m) {
  long long d = gcd(n, m);
  n /= d;
  m /= d;
  if (m == 1)
    return n;
  else
    return n / m + 1;
}
void solve() {
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]), sum[i] = sum[i - 1] + a[i];
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (i >= j)
        dp[i][j] =
            max(sum[i] - sum[i - j], sum[i] - sum[i - j] + dp[i - j][m]) - k;
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
int main(void) {
  cin >> n >> m >> k;
  solve();
  return 0;
}
