#include <bits/stdc++.h>
using namespace std;
int n, m, w, a[200010], b[200010];
long long c[200010];
void add(int x, long long v) {
  for (int i = x; i <= n; i += (i & -i)) c[i] += v;
}
long long ask(int x) {
  long long res = 0;
  for (int i = x; i > 0; i -= (i & -i)) res += c[i];
  return res;
}
bool ok(int x) {
  for (int i = 1; i <= n; i++) {
    b[i] = max(0, x - a[i]);
  }
  long long res = 0;
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; i++) {
    long long tmp = ask(i);
    if (b[i] > tmp) {
      res += b[i] - tmp;
      add(i, b[i] - tmp);
      add(i + w, tmp - b[i]);
    }
  }
  return res <= m;
}
int main() {
  cin >> n >> m >> w;
  int l = 0x3f3f3f3f, r = 0x3f3f3f3f, mid;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l = min(a[i], l);
  }
  while (l <= r) {
    mid = (l + r) >> 1;
    if (ok(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << r << endl;
  return 0;
}
