#include <bits/stdc++.h>
using namespace std;
const long long oo = 1ll << 17;
const long long mos = 0x7FFFFFFF;
const long long nmos = 0x80000000;
const int inf = 0x3f3f3f3f;
const long long inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9;
const double esp = 1e-8;
const double PI = acos(-1.0);
const double PHI = 0.61803399;
const double tPHI = 0.38196601;
template <typename T>
inline T read(T &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
inline void cmax(int &x, int y) {
  if (x < y) x = y;
}
inline void cmax(long long &x, long long y) {
  if (x < y) x = y;
}
inline void cmin(int &x, int y) {
  if (x > y) x = y;
}
inline void cmin(long long &x, long long y) {
  if (x > y) x = y;
}
const int maxn = 1e5 + 9;
int n, m, w;
long long a[maxn];
bool check(long long val) {
  queue<pair<int, int> > que;
  long long sum = 0;
  int t = 0;
  for (int i = 1; i <= n; i++) {
    while (!que.empty() && que.front().first + w <= i) {
      sum -= que.front().second;
      que.pop();
    }
    if (a[i] + sum >= val) continue;
    long long tmp = val - a[i] - sum;
    t += tmp;
    if (t > m) return false;
    sum += tmp;
    que.push(pair<int, int>(i, tmp));
  }
  return true;
}
int main() {
  scanf("%d%d%d", &n, &m, &w);
  long long mn = inf;
  for (int i = (1); i <= (n); ++i) scanf("%lld", &a[i]), mn = min(mn, a[i]);
  int le = 0, ri = m, res = -1;
  while (le <= ri) {
    int mid = (le + ri) >> 1;
    if (check(mn + mid))
      le = mid + 1, res = mid;
    else
      ri = mid - 1;
  }
  printf("%lld\n", mn + res);
  return 0;
}
