#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 300010, LOG = 20;
long long n, m, k, u, v, x, y, t, a, b;
long double ps[MAXN];
long double mn[10];
long double ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    cin >> ps[i], ps[i] += ps[i - 1] - (((long double)k) / m);
  for (int j = 1; j < m; j++) mn[j] = 1e15;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      ans = max(ans,
                ps[i] - mn[(i + m - j) % m] - (j > 0) * (m - j) * (1. * k / m));
    }
    mn[i % m] = min(mn[i % m], ps[i]);
  }
  cerr << "ans" << '=' << (ans) << endl;
  long long tmp = ans;
  if (ans - tmp >= .5) tmp++;
  cout << tmp << '\n';
  return 0;
}
