#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define int long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mode 998244353
#define mx 500005
#define inf 2e18
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int arr[mx];
ll dp[mx];
int n,r;
vector<int> v;
vector<ll> defense;
ll k;
ll lazy[2*mx];
bool f(ll mid)
{
	ll cnt = 0;
	int id = -100000000;
	ll mn = inf;
	ll val = 0;
	memset(lazy,0,sizeof(lazy));
	fl(i,1,n+1)
	{
	//	cout<<dp[i]<<" ";
		val += lazy[i];
		if(dp[i] + val < mid)
		{
			lazy[i + 2*r + 1] -= mid - dp[i] - val;
		//	cout<<i+2*r+1<<" "<<mid-dp[i]-val<<endl;
			ll x = mid - dp[i] - val;
			val += x;
			cnt += x;
			if(cnt > k)
				break;
		}
//		cout<<val<<endl;
	}
//	cout<<cnt;
	return cnt <= k;
}
main()
{
	fast;

	cin>>n>>r>>k;
	fl(i,1,n+1)
	{
		cin>>arr[i];
		int start = max(i - r, 1LL);
		int end = min(n,i + r);
		dp[start] += arr[i];
		dp[end+1] -= arr[i];
	}
	fl(i,1,n+1)
	{
		dp[i] += dp[i-1];
	//	cout<<dp[i]<<" ";
	}
	int loc = 0;

	ll low = 0, high = k + dp[1] , mid; // low = 0 -_-
	while(low < high)
	{
		mid = (low + high) /2 + (low+high)%2;
		if(f(mid))
		{
			low = mid;
		}
		else
		{
			high = mid - 1;
		}
	}
	cout<<low;

}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mode 998244353
#define mx 500005
#define inf 2e18
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int arr[mx];
ll dp[mx];
int n,r;
vector<int> v;
vector<ll> defense;
ll k;
bool f(ll mid)
{
	ll cnt = 0;
	int id = -100000000;
	ll mn = inf;
	fl(i,1,n+1)
	{
	//	cout<<dp[i]<<" ";
		if(dp[i] < mid)
		{
			if(id < i - r)
			{
				id = i + r;
				cnt += max(0LL,mid-mn);
				mn = dp[i];
			}
			else
			{
				mn = min(mn,dp[i]);
			}
		}
		else continue;
	}
	cnt += max(0LL,mid-mn);
//	cout<<cnt;
	return cnt <= k;
}
main()
{
	fast;

	cin>>n>>r>>k;
	fl(i,1,n+1)
	{
		cin>>arr[i];
		int start = max(i - r, 1);
		int end = min(n,i + r);
		dp[start] += arr[i];
		dp[end+1] -= arr[i];
	}
	fl(i,1,n+1)
	{
		dp[i] += dp[i-1];
	}
	int loc = 0;

	ll low = 0, high = 2e18 , mid; // low = 0 -_-
	while(low < high)
	{
		mid = (low + high) /2 + (low+high)%2;
		if(f(mid))
		{
			low = mid;
		}
		else
		{
			high = mid - 1;
		}
	}
	cout<<low;

}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define int long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mode 998244353
#define mx 500005
#define inf 2e18
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int arr[mx];
ll dp[mx];
int n,r;
vector<int> v;
vector<ll> defense;
ll k;
bool f(ll mid)
{
	ll cnt = 0;
	int id = -100000000;
	ll mn = inf;
	fl(i,1,n+1)
	{
	//	cout<<dp[i]<<" ";
		if(dp[i] < mid)
		{
			if(id < i - r)
			{
				id = i + r;
				cnt += max(0LL,mid-mn);
				mn = dp[i];
			}
			else
			{
				mn = min(mn,dp[i]);
			}
		}
		else continue;
	}
	cnt += max(0LL,mid-mn);
//	cout<<cnt;
	return cnt <= k;
}
main()
{
	fast;

	cin>>n>>r>>k;
	fl(i,1,n+1)
	{
		cin>>arr[i];
		int start = max(i - r, 1LL);
		int end = min(n,i + r);
		dp[start] += arr[i];
		dp[end+1] -= arr[i];
	}
	fl(i,1,n+1)
	{
		dp[i] += dp[i-1];
	}
	int loc = 0;

	ll low = 0, high = k + dp[1] , mid; // low = 0 -_-
	while(low < high)
	{
		mid = (low + high) /2 + (low+high)%2;
		if(f(mid))
		{
			low = mid;
		}
		else
		{
			high = mid - 1;
		}
	}
	cout<<low;

}


#include<cstdio>
#include<algorithm>
#include<memory.h>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

int main(){
    scanf("%d%d%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    long long l = 0, r = 1e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, b[N], dp[N], pref[N];

inline bool check(long long x){
    for(int i = 1; i <= n; i++){
        dp[i] = 0;
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        dp[i] += dp[i - 1];
        if(dp[i] + b[i] < x){
            long long y = x - dp[i] - b[i];
            dp[i] += y;
            dp[min(n + 1, i + m + m + 1)] -= y;
            cur += y;
            if(cur > k){
                return false;
            }
        }
    }
    return true;
}

int main(){
    scanf("%d%d%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1; i <= n; i++){
        b[i] = pref[min(n, i + m)] - pref[max(0, i - m - 1)];
    }
    long long l = 0, r = 2e18 + 100;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
#define int long long
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1ll, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

signed main(){
    scanf("%lld%lld%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
    }
    long long l = 0, r = 9e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
#define int long long
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1ll, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

signed main(){
    scanf("%lld%lld%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
    }
    long long l = 0, r = 5e15;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

signed main(){
    scanf("%d%d%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    long long l = 0, r = 6e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N], f[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    for(int i = 1; i <= n; i++){
        t[i] = f[i];
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

void upd1(int pos, int val){
    for(int i = pos; i <= n; i |= i + 1){
        f[i] += val;
    }
}

int main(){
    scanf("%d%d%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        upd1(i, a[i]);
    }
    long long l = 0, r = 2e18 + 100;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 5e5 + 5;

int n, m, k, a[N];
long long t[4 * N];

void build(int v, int l, int r){
    if(l == r){
        t[v] = a[l];
        return;
    }
    int mid = (r + l) >> 1;
    build(v + v, l, mid);
    build(v + v + 1, mid + 1, r);
    t[v] = t[v + v] + t[v + v + 1];
}

long long get(int v, int l, int r, int tl, int tr){
    if(tl <= l && r <= tr){
        return t[v];
    }
    int mid = (r + l) >> 1;
    long long y = 0;
    if(tl <= mid){
        y += get(v + v, l, mid, tl, tr);
    }
    if(tr > mid){
        y += get(v + v + 1, mid + 1, r, tl, tr);
    }
    return y;
}

void update(int v, int l, int r, int pos, long long val){
    t[v] += val;
    if(l == r){
        return;
    }
    int mid = (r + l) >> 1;
    if(pos <= mid){
        update(v + v, l, mid, pos, val);
    }
    else{
        update(v + v + 1, mid + 1, r, pos, val);
    }
}

inline bool check(long long x){
    build(1, 1, n);
    long long cur = 0;
    for(int i = m; i <= min(n, m + m - 1); i++){
        if(long long y = get(1, 1, n, 1, i) < x){
            cur += x - y;
            if(cur > k){
                return false;
            }
            update(1, 1, n, i, x - y);
        }
    }
    for(int i = m + m; i <= n; i++){
        if(long long y = get(1, 1, n, i - m - m + 2, i) < x){
            cur += x - y;
            if(cur > k){
                return false;
            }
            update(1, 1, n, i, x - y);
            break;
        }
    }
    return true;
}

int main(){
    scanf("%d%d%lld", &n, &m, &k);
    m++;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    long long l = 0, r = 1e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

signed main(){
    scanf("%d%d%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    long long l = 0, r = 2e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
#include<memory.h>
#define int long long
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[N];

inline long long get(int pos){
    long long cur = 0;
    for(int i = pos; i >= 1; i &= i + 1, i--){
        cur += t[i];
    }
    return cur;
}

inline void upd(int pos, long long val){
    for(int i = pos; i <= n; i |= i + 1){
        t[i] += val;
    }
}

inline bool check(long long x){
    memset(t, 0, sizeof(t));
    for(int i = 1; i <= n; i++){
        upd(i, a[i]);
    }
    long long cur = 0;
    for(int i = 1; i <= n; i++){
        int l = max(1ll, i - m), r = min(n, i + m);
        long long val = get(r) - get(l - 1);
        if(val >= x){
            continue;
        }
        long long y = x - val;
        cur += y;
        if(cur > k){
            return false;
        }
        upd(r, y);
    }
    return true;
}

signed main(){
    scanf("%lld%lld%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
    }
    long long l = 0, r = 1e9;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 5e5 + 5;

int n, m, a[N];
long long k, t[4 * N];

void build(int v, int l, int r){
    if(l == r){
        t[v] = a[l];
        return;
    }
    int mid = (r + l) >> 1;
    build(v + v, l, mid);
    build(v + v + 1, mid + 1, r);
    t[v] = t[v + v] + t[v + v + 1];
}

long long get(int v, int l, int r, int tl, int tr){
    if(tl <= l && r <= tr){
        return t[v];
    }
    int mid = (r + l) >> 1;
    long long y = 0;
    if(tl <= mid){
        y += get(v + v, l, mid, tl, tr);
    }
    if(tr > mid){
        y += get(v + v + 1, mid + 1, r, tl, tr);
    }
    return y;
}

void update(int v, int l, int r, int pos, long long val){
    t[v] += val;
    if(l == r){
        return;
    }
    int mid = (r + l) >> 1;
    if(pos <= mid){
        update(v + v, l, mid, pos, val);
    }
    else{
        update(v + v + 1, mid + 1, r, pos, val);
    }
}

inline bool check(long long x){
    build(1, 1, n);
    long long cur = 0;
    for(int i = m; i <= min(n, m + m - 1); i++){
        if(long long y = get(1, 1, n, 1, i) < x){
            cur += x - y;
            if(cur > k){
                return false;
            }
            update(1, 1, n, i, x - y);
        }
    }
    for(int i = m + m; i <= n; i++){
        if(long long y = get(1, 1, n, i - m - m + 2, i) < x){
            cur += x - y;
            if(cur > k){
                return false;
            }
            update(1, 1, n, i, x - y);
            break;
        }
    }
    return true;
}

int main(){
    scanf("%d%d%lld", &n, &m, &k);
    m++;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    long long l = 0, r = 1e18;
    while(r - l > 1){
        long long mid = (r + l) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(check(r)){
        printf("%lld", r);
    }
    else{
        printf("%lld", l);
    }
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    deque<ll> q;
    ll rem = k , lst = 0;
    for(int i = r + 1;i >= 1;i--) {
        ll cnt = max(0ll , x - a[i] - lst);
        if(rem - cnt < 0)
            return false;
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    for(int i = r + 2;i <= n;i++) {
        lst -= q.front();
        q.pop_front();
        ll cnt = max(0ll , x - a[i] - lst);
        if(rem - cnt < 0)
            return false;
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    return true;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    if(n == 1)
        return cout << a[1] + k , 0;
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , mn = -1e18;
    multiset<ll> mx;
    deque<ll>q;
    vector<pair<ll , int>> v;
    for(int i = 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            v.push_back({x - mn , i - 1});
            mn = 1e18;
        }
        mn = min(mn , a[i]);
    }
    v.push_back({x - mn , n});
    sort(v.begin() , v.end());
    mn = 2e18;
    for(int i = v[0].second;i >= 1;i--) {
        if((i + 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i + 1;
            while(j <= n && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j++ , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , a[i] + m);
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    for(int i = v[0].second + 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i - 1;
            while(j > 0 && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j-- , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , a[i] + m);
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    rem -= max(0ll , x - mn);
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , mn = x;
    multiset<ll> mx;
    deque<ll>q;
    for(int i = 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i - 1;
            while(j > 0 && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j-- , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , a[i] + m);
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    rem -= max(0ll , x - mn);
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    set<int> st;
    for(int i = 1;i <= n;i++)
        st.insert(i);
    ll rem = k;
    for(auto &i : v) {
        if(!st.count(i.second))
            continue;
        rem -= max(0ll , x - i.first);
        st.erase(i.second);
        auto it = st.upper_bound(i.second);
        while(abs(*it - i.second) <= r) {
            auto tmp = it;
            st.erase(it);
            it = st.upper_bound(*tmp);
        }
        it = st.lower_bound(i.second);
        if(it == st.begin())
            continue;
        it--;
        while(abs(*it - i.second) <= r) {
            auto tmp = it;
            st.erase(it);
            it = st.lower_bound(*tmp);
            if(it == st.begin())
                break;
            it--;
        }
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
        v.push_back({a[i] , i});
    }
    sort(v.begin() , v.end());
    ll low = 1 , high = 2e18 , mid , ans;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N] , b[N];
bool check(ll x) {
    ll rem = k , acc = 0;
    deque<pair<ll , int>> q;
    for(int i = 1;i <= n;i++)
        b[i] = a[i];
    for(int i = 1;i <= n;i++) {
        while(q.size() && i > q.front().second + r)
            acc -= q.front().first , q.pop_front();
        if(b[i] + acc < x) {
            ll cnt = x - (b[i] + acc);
            acc += cnt;
            q.push_back({cnt , min(i + 2 * r , n)});
            rem -= cnt;
            if(rem < 0)
                return false;
        }
    }
    return true;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    set<int> st;
    for(int i = 1;i <= n;i++)
        st.insert(i);
    ll rem = k;
    for(auto &i : v) {
        if(!st.count(i.second))
            continue;
        rem -= max(0ll , x - i.first);
        st.erase(i.second);
        auto it = st.upper_bound(i.second);
        if(it != st.end()) {
            while(abs(*it - i.second) <= r) {
                auto tmp = it;
                st.erase(it);
                it = st.upper_bound(*tmp);
                if(it == st.end())
                    break;
            }
        }
        it = st.lower_bound(i.second);
        if(it == st.begin())
            continue;
        it--;
        while(abs(*it - i.second) <= r) {
            auto tmp = it;
            st.erase(it);
            it = st.lower_bound(*tmp);
            if(it == st.begin())
                break;
            it--;
        }
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
        v.push_back({a[i] , i});
    }
    sort(v.begin() , v.end());
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    deque<ll> q;
    ll rem = k , lst = 0;
    for(int i = r + 1;i >= 1;i--) {
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    for(int i = r + 2;i <= n;i++) {
        lst -= q.front();
        q.pop_front();
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    if(n == 1)
        return cout << a[1] + k , 0;
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , acc = 0;
    deque<pair<ll , int>> q;
    for(int i = 1;i <= n;i++) {
        while(q.size() && i > q.front().second)
            acc -= q.front().first , q.pop_front();
        if(a[i] + acc < x) {
            ll cnt = x - (a[i] + acc);
            acc += cnt;
            q.push_back({cnt , min(i + 2 * r , n)});
            rem -= cnt;
            if(rem < 0)
                return false;
        }
    }
    return true;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , mn = x;
    multiset<ll> mx;
    deque<ll>q;
    for(int i = 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i - 1;
            while(j > 0 && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j-- , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , max(0ll , a[i] - m));
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    rem -= max(0ll , x - mn);
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    deque<ll> q;
    ll rem = k , lst = 0;
    for(int i = r + 1;i >= 1;i--) {
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    for(int i = r + 2;i <= n;i++) {
        lst -= q.front();
        q.pop_front();
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    if(n == 1)
        return cout << a[0] + k , 0;
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N] , b[N];
bool check(ll x) {
    ll rem = k , acc = 0;
    deque<pair<ll , int>> q;
    for(int i = 1;i <= n;i++)
        b[i] = a[i];
    for(int i = 1;i <= n;i++) {
        while(q.size() && i >= q.front().second)
            acc -= q.front().first , q.pop_front();
        if(b[i] + acc < x) {
            ll cnt = x - (b[i] + acc);
            b[min(i + r , n)] += cnt;
            acc += cnt;
            q.push_back({cnt , min(i + r + 1 , n + 1)});
            rem -= cnt;
            if(rem < 0)
                return false;
        } else {
            ll cnt = b[i] - a[i];
            acc += cnt;
            q.push_back({cnt , min(i + r + 1 , n + 1)});
        }
    }
    return true;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , mn = -1e18;
    multiset<ll> mx;
    deque<ll>q;
    vector<pair<ll , int>> v;
    for(int i = 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            v.push_back({x - mn , i - 1});
            mn = 1e18;
        }
        mn = min(mn , a[i]);
    }
    v.push_back({x - mn , n});
    sort(v.begin() , v.end());
    mn = 1e18;
    for(int i = v[0].second;i >= 1;i--) {
        if((i + 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i + 1;
            while(j <= n && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j++ , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , a[i] + m);
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    for(int i = v[0].second + 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            int cnt = 0 , j = i - 1;
            while(j > 0 && cnt < r){
                q.push_front(max(0ll , x - a[j]));
                mx.insert(max(0ll , x - a[j]));
                j-- , cnt++;
            }
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        ll m = 0;
        if(mx.size())
            m = *mx.rbegin();
        mn = min(mn , a[i] + m);
        if(mx.size()) {
            mx.erase(mx.find(q.front()));
            q.pop_front();
        }
    }
    rem -= max(0ll , x - mn);
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    set<int> st;
    for(int i = 1;i <= n;i++)
        st.insert(i);
    ll rem = k;
    for(auto &i : v) {
        if(!st.count(i.second))
            continue;
        rem -= max(0ll , x - i.first);
        st.erase(i.second);
        auto it = st.upper_bound(i.second);
        while(abs(*it - i.second) <= r) {
            auto tmp = it;
            st.erase(it);
            it = st.upper_bound(*tmp);
        }
        it = st.lower_bound(i.second);
        if(it == st.begin())
            continue;
        it--;
        while(abs(*it - i.second) <= r) {
            auto tmp = it;
            st.erase(it);
            it = st.lower_bound(*tmp);
            if(it == st.begin())
                break;
            it--;
        }
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
        v.push_back({a[i] , i});
    }
    sort(v.begin() , v.end());
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    deque<ll> q;
    ll rem = k , lst = 0;
    for(int i = r + 1;i >= 1;i--) {
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    for(int i = r + 2;i <= n;i++) {
        lst -= q.front();
        q.pop_front();
        ll cnt = max(0ll , x - a[i] - lst);
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r;
ll k , pref[N] , a[N];
bool check(ll x) {
    ll rem = k , mn = x;
    for(int i = 1;i <= n;i++) {
        if((i - 1) % (2 * r + 1) == 0) {
            if(rem - max(0ll , x - mn) < 0)
                return false;
            rem -= max(0ll , x - mn);
            mn = 1e18;
        }
        mn = min(mn , a[i]);
    }
    rem -= max(0ll , x - mn);
    return rem >= 0;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 0 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 5e5 + 5;
int n , r , a[N];
ll k , pref[N];
vector<pair<ll , int>> v;
bool check(ll x) {
    deque<ll> q;
    ll rem = k , lst = 0;
    for(int i = min(n , r + 1);i >= 1;i--) {
        ll cnt = max(0ll , x - a[i] - lst);
        if(rem - cnt < 0)
            return false;
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    for(int i = r + 2;i <= n;i++) {
        lst -= q.front();
        q.pop_front();
        ll cnt = max(0ll , x - a[i] - lst);
        if(rem - cnt < 0)
            return false;
        rem -= cnt , lst += cnt;
        q.push_front(cnt);
    }
    return true;
}
int main() {
    abdelrahman010
    cin >> n >> r >> k;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    if(n == 1)
        return cout << a[1] + k , 0;
    for(int i = 1;i <= n;i++) {
        a[i] = a[i] + pref[i - 1] - pref[max(0 , i - r - 1)];
        a[i] = a[i] + pref[min(i + r , n)] - pref[i];
    }
    ll low = 1 , high = 2e18 , mid , ans = 0;
    while(low <= high) {
        mid = low + high >> 1;
        if(check(mid))
            ans = mid , low = mid + 1;
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>r>>k;
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)cin>>A[i],update(i,A[i]);

    ll L = 0, R = 2e18+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    if(r==n)r=n-1;
    vector<ll>A(n+2);
    //vector<ll>B(n+2,0);
    vector<ll>P(n+2);
    for(int i=1; i<=n; i++)cin>>A[i],P[i]=P[i-1]+A[i];

    ll L = 0, R = 2e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        ll sum = 0;
        ll extra = 0;
        vector<ll>B(n+2,0);

        for(int i=1; i<=n && left >= 0; i++)
        {
            //cout<<i<<" extra="<<extra<<" B[i]="<<B[i]<<"\n";
            extra+=B[i];
            B[i]=0;
            ll sum = - P[max(i-r-1,0LL)] + P[min(i+r,n)] + extra;
            //cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<< P[i] - P[max(i-r-1,0LL)]
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<P[min(i+r,n)]-P[i]<<endl;

            //cout<<"Total sum: "<<sum<<" "<<extra<<"\n";
            if(sum < rel)
            {
                ll need = rel-sum;
                extra+=need;
                if(i+2*r+1 <=n)
                B[i+2*r+1]-=need;
                left-=need;
            }
        }

        //cout<<L<<" "<<R<<" "<<rel<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r,x;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    //ios::sync_with_stdio(0);
    scanf("%d %d %I64d", &n, &r, &k);
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)scanf("%d",&x),update(i,x);

    ll L = 0, R = 2e18+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    printf("%I64d\n",R);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r,x;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    //ios::sync_with_stdio(0);
    scanf("%d %d %I64d", &n, &r, &k);
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)scanf("%d",&x),update(i,x);

    ll L = 0, R = 2e18+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    printf("%d\n",R);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    if(r==n)r=n-1;
    vector<ll>A(n);
    vector<ll>B(n);
    for(ll&x:A)cin>>x;

    ll L = 0, R = 2e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        ll sum = 0;
        B=A;
        for(int i=0; i<=r; i++)
            sum+=B[i];

        if(sum<rel)left-=rel-sum,B[r]+=rel-sum,sum+=rel-sum;

        for(int i=r+1; i<n && left >= 0; i++)
        {
            sum-=B[i-r-1];
            sum+=B[i];
            if(sum<rel)left-=rel-sum,B[i]+=rel-sum,sum+=rel-sum;
        }

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll query(vector<ll>&seg, int c, int l, int r, int L, int R)
{
    if(l>R || r<L)return 0LL;

    if(l>=L && r<=R)return seg[c];

    int m = (l+r)/2;

    return query(seg,2*c,l,m,L,R) + query(seg,2*c+1,m+1,r,L,R);
}

void update(vector<ll>&seg, int c, int l, int r, int pos, ll val)
{
    if(l==r)
    {
        seg[c]+=val;
        return;
    }

    int m = (l+r)/2;
    if(pos<=m)update(seg,2*c,l,m,pos,val);
    else update(seg,2*c+1,m+1,r,pos,val);

    seg[c]=seg[2*c]+seg[2*c+1];
}

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)cin>>A[i];

    ll L = 0, R = 2*k+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        vector<ll>seg(4*n+4);

        for(int i=1; i<=n; i++)update(seg,1,1,n,i,A[i]);

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(seg,1,1,n,i-r,i) + query(seg,1,1,n,i+1,i+r);
            //cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(seg,1,1,n,i-r,i)<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(seg,1,1,n,i+1,i+r)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(seg,1,1,n,i,need);
                left-=need;
            }
        }

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r,x,mx;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    //ios::sync_with_stdio(0);
    scanf("%d %d %I64d", &n, &r, &k);
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)scanf("%d",&x),update(i,x);

    ll L = 0, R = k+1e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    printf("%I64d\n",R);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

inline void inp( ll &n )//fast input function
{
   n=0;
   int ch=getchar();int sign=1;
   while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}

   while(  ch >= '0' && ch <= '9' )
           n = (n<<3)+(n<<1) + ch-'0', ch=getchar();
   n=n*sign;
}

ll n,r,x,mx;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    //ios::sync_with_stdio(0);
    //scanf("%d %d %I64d", &n, &r, &k);
    inp(n);
    inp(r);
    inp(k);
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)inp(x),update(i,x);

    ll L = 0, R = 2e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0LL));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    printf("%I64d\n",R);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>r>>k;
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)cin>>A[i],update(i,A[i]);

    ll L = 0, R = 2e18+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll query(vector<ll>&seg, int c, int l, int r, int L, int R)
{
    if(l>R || r<L)return 0LL;

    if(l>=L && r<=R)return seg[c];

    int m = (l+r)/2;

    return query(seg,2*c,l,m,L,R) + query(seg,2*c+1,m+1,r,L,R);
}

void update(vector<ll>&seg, int c, int l, int r, int pos, ll val)
{
    if(l==r)
    {
        seg[c]+=val;
        return;
    }

    int m = (l+r)/2;
    if(pos<=m)update(seg,2*c,l,m,pos,val);
    else update(seg,2*c+1,m+1,r,pos,val);

    seg[c]=seg[2*c]+seg[2*c+1];
}

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)cin>>A[i];

    ll L = 0, R = 2*k+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        vector<ll>seg(4*n+4);

        for(int i=1; i<=n; i++)update(seg,1,1,n,i,A[i]);

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(seg,1,1,n,i-r,i) + query(seg,1,1,n,i+1,i+r);
            //cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(seg,1,1,n,i-r,i)<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(seg,1,1,n,i+1,i+r)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(seg,1,1,n,min(i+r,n),need);
                left-=need;
            }
        }

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n,r,x,mx;
ll BIT[500001],k,temp[500001];

ll update(int c, ll val)
{
    for(;c<=n; c+=(c&-c))
        BIT[c]+=val;
}

ll query(int c)
{
    ll sum = 0;
    for(;c>0;c-=(c&-c))
        sum+=BIT[c];
    return sum;
}

int main()
{
    //ios::sync_with_stdio(0);
    scanf("%d %d %I64d", &n, &r, &k);
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)scanf("%d",&x),update(i,x);

    ll L = 0, R = 2e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(min(i+r,n)) - query(max(i-r-1,0));
           // cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(i) - query(max(i-r-1,0))
            //<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(min(i+r,n)) - query(i-1)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(min(i+r,n),need);
                temp[min(i+r,n)]+=need;
                left-=need;
            }
        }

        for(int i=1; i<=n; i++)
            update(i,-temp[i]),temp[i]=0;

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    printf("%I64d\n",R);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll query(vector<ll>&seg, int c, int l, int r, int L, int R)
{
    if(l>R || r<L)return 0LL;

    if(l>=L && r<=R)return seg[c];

    int m = (l+r)/2;

    return query(seg,2*c,l,m,L,R) + query(seg,2*c+1,m+1,r,L,R);
}

void update(vector<ll>&seg, int c, int l, int r, int pos, ll val)
{
    if(l==r)
    {
        seg[c]+=val;
        return;
    }

    int m = (l+r)/2;
    if(pos<=m)update(seg,2*c,l,m,pos,val);
    else update(seg,2*c+1,m+1,r,pos,val);

    seg[c]=seg[2*c]+seg[2*c+1];
}

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    vector<ll>A(n+1);

    for(int i=1; i<=n; i++)cin>>A[i];

    ll L = 0, R = 2e18+2e9;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        vector<ll>seg(4*n+4);

        for(int i=1; i<=n; i++)update(seg,1,1,n,i,A[i]);

        for(int i=1; i<=n && left >= 0; i++)
        {
            ll sum = query(seg,1,1,n,i-r,i) + query(seg,1,1,n,i+1,i+r);
            //cout<<i<<" sum of ["<<i-r<<" "<<i<<"] is "<<query(seg,1,1,n,i-r,i)<<" sum of ["<<i+1<<" "<<i+r<<"] is "<<query(seg,1,1,n,i+1,i+r)<<endl;

            if(sum < rel)
            {
                ll need = rel-sum;
                update(seg,1,1,n,min(i+r,n),need);
                left-=need;
            }
        }

        //cout<<rel<<" "<<left<<"\n";

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    vector<ll>A(n);
    vector<ll>B(n);
    for(ll&x:A)cin>>x;

    ll L = 0, R = 1e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        ll sum = 0;
        B=A;
        for(int i=0; i<=r; i++)
            sum+=B[i];

        if(sum<rel)left-=rel-sum,B[r]+=rel-sum,sum+=rel-sum;

        for(int i=r+1; i<n; i++)
        {
            sum-=B[i-r-1];
            sum+=B[i];
            if(sum<rel)left-=rel-sum,B[i]+=rel-sum,sum+=rel-sum;
        }

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ios::sync_with_stdio(0);
    ll n,r,k;
    cin>>n>>r>>k;
    vector<ll>A(n);
    vector<ll>B(n);
    for(ll&x:A)cin>>x;

    ll L = 0, R = 2e18;

    while(L<R)
    {
        ll rel = L + (R-L+1)/2;
        ll left = k;
        ll sum = 0;
        B=A;
        for(int i=0; i<=r; i++)
            sum+=B[i];

        if(sum<rel)left-=rel-sum,B[r]+=rel-sum,sum+=rel-sum;

        for(int i=r+1; i<n; i++)
        {
            sum-=B[i-r-1];
            sum+=B[i];
            if(sum<rel)left-=rel-sum,B[i]+=rel-sum,sum+=rel-sum;
        }

        if(left>=0)
            L=rel;
        else
            R=rel-1;
    }

    cout<<R<<"\n";
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	asset(hi <= 2000000000000000000LL);
	// hi = 2000000000000000000LL; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	// assert(check(lo+1) == false);
	// assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	// assert(hi <= 2000000000000000000LL);
	hi = 2000000000000000000LL; // bump it up just in case
								//somehow this causes it to fail
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	assert(check(lo+1) == false);
	assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	assert(hi <= 2000000000000000000LL);
	// hi = 2000000000000000000LL; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	// assert(check(lo+1) == false);
	// assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {
	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i];
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd;
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL;
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL;
	}
	fill(rel, rel+maxn, 0LL);

	ll cv = 0LL;
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	while (lo < hi) {
		ll diff = hi-lo;
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	hi = 2LL*hi; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {
	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL;
	}
	ll kleft = k;
	for (int i = 1; i <= n; i++) {
		cv -= sub[i];
		if (cv + rel[i] < cur) {
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd;
			cv += cadd;
			int en = min(n, i+2*r);
			sub[en+1]+=cadd;
		}
	}
	return kleft >= 0LL;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL;
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL;
	}
	fill(rel, rel+maxn, 0LL);

	ll cv = 0LL;
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0;
	ll hi = n+ksum;
	while (lo < hi) {
		ll mid = (lo+hi+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL;
		}
	}
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;
	assert(n == 10);

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	hi = 2LL*hi; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	// assert(lo == hi);
	// assert(check(lo+1) == false);
	// assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	hi = 2LL*hi; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	assert(check(lo+1) == false);
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	hi = 2000000000000000000LL; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	// assert(check(lo+1) == false);
	// assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1] += cadd; //no longer active here

		}
		if (kleft < 0) return false; //maybe overflow here
	}
	if (kleft >= 0LL) return true;
	return false; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1] += val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	// assert(hi <= 2000000000000000000LL);
	hi = 2000000000000000000LL; // bump it up just in case
								//somehow this causes it to fail
								//this should work
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	assert(check(lo+1) == false); //somehow this evaluates  and still gets WA
	assert(check(lo));
	//somehow the binary search can find different answers and still say
	//    each is ok. this does not make sense (the bin search should satisfy
	//    binary search condition regardless)

	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	// hi = 2000000000000000000LL; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	// assert(check(lo+1) == false);
	// assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1]+=cadd; //no longer active here
		}
	}
	return kleft >= 0LL; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	hi = 2LL*hi; // bump it up just in case
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	assert(check(lo+1) == false);
	assert(check(lo));
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {
	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL;
	}
	ll kleft = k;
	for (int i = 1; i <= n; i++) {
		cv -= sub[i];
		if (cv + rel[i] < cur) {
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd;
			cv += cadd;
			int en = min(n, i+2*r);
			sub[en+1]+=cadd;
		}
	}
	return kleft >= 0LL;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL;
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1]+=val;
		ksum += val+0LL;
	}
	fill(rel, rel+maxn, 0LL);

	ll cv = 0LL;
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0;
	ll hi = k+ksum;
	while (lo < hi) {
		ll mid = (lo+hi+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL;
		}
	}
	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define maxn 500010

ll rel[maxn]; //initial reliability
ll sub[2*maxn]; //to be used in the binary search code
ll addon[2*maxn]; // only in initial guy
int n, r;
ll k;

bool check(ll cur) {

	//can we get to at least cur for everything

	ll cv = 0LL;
	for (int i = 0; i <= n; i++) {
		sub[i] = 0LL; //just a manual fill
	}
	ll kleft = k; //the amount left at start is everything
	for (int i = 1; i <= n; i++) {
		cv -= sub[i]; //what is no longer active
		assert(cv >= 0LL);
		if (cv + rel[i] < cur) { //the reliability of this point now
			ll cadd = cur-(cv+rel[i]);
			kleft -= cadd; //subtract out what he had to add here
			cv += cadd;
			int en = min(n, i+2*r); //last guy we affect
			sub[en+1] += cadd; //no longer active here
		}
	}
	if (kleft >= 0LL) return true;
	return false; //see if we overused archers
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> r >> k;

	ll val;
	fill(sub, sub+2*maxn, 0LL);
	fill(addon, addon+2*maxn, 0LL);
	ll ksum = 0LL; //total number of archers seen at beginning
	for (int i = 1; i <= n; i++) {
		cin >> val;
		int st = max(i-r, 1);
		addon[st] += val;
		int en = min(n, i+r);
		sub[en+1] += val;
		ksum += val+0LL; //contribute to the whole
	}
	fill(rel, rel+maxn, 0LL); // just a precaution

	ll cv = 0LL; //curvalue
	for (int i = 1; i <= n; i++) {
		cv += addon[i];
		cv -= sub[i];
		rel[i] = cv;
		assert(cv >= 0LL);
		// cout << "rel  " << i << " " << rel[i] << endl;
	}

	ll lo = 0LL;
	ll hi = k+ksum;
	// assert(hi <= 2000000000000000000LL);
	hi = 2000000000000000000LL; // bump it up just in case
								//somehow this causes it to fail
								//this should work
	while (lo < hi) {
		ll diff = hi-lo; //try to prevent overflow
		ll mid = lo + (diff+1LL)/2LL;
		// cout << "checking  " << mid << endl;
		if (check(mid)) { //this is attainable
			lo = mid;
		}
		else {
			hi = mid-1LL; //can't even get this thing
		}
	}
	assert(lo == hi);
	assert(check(lo+1) == false); //somehow this evaluates  and still gets WA
	assert(check(lo));
	//somehow the binary search can find different answers and still say
	//    each is ok. this does not make sense (the bin search should satisfy
	//    binary search condition regardless)

	cout << lo << endl;
	cin >> n;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 6e5 + 7;

ll bit[maxn];
ll bitc[maxn];
ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bit[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        while (x < maxn) {
                bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        for (int i = 0; i < maxn; i++) bitc[i] = bit[i];
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                //cout << v << " ~ " << s << " : " << endl;
                if (s < v) {
                        if (rem < v - s) {
                                for (int i = 0; i < maxn; i++) bit[i] = bitc[i];
                                return false;
                        }
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        for (int i = 0; i < maxn; i++) bit[i] = bitc[i];
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x; cin >> x; upd(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e9*1e6);
	while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 6e5 + 7;

ll bit[maxn];

ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bit[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        while (x < maxn) {
                bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                if (s < v) {
                        if (rem < v - s) return false;
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x; cin >> x; upd(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e9*1e6);
	while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 5e5 + 7;

ll a[maxn];
ll adds[maxn];

int n, rg; ll k;

bool check(ll v) {
        for (int j = 0; j <= n; j++) adds[j] = 0;
        ll rem = k, s = 0;
        for (int j = 1; j <= rg + 1; j++) s += a[j];
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                if (s < v) {
                        ll d = v - s;
                        if (rem < d) return false;
                        rem -= d;
                        adds[r] += d;
                        s += d;
                }
                if (max(1, i + 1 - rg) > l) s -= adds[l] + a[l];
                if (min(n, i + 1 + rg) > r) s += a[min(n, i + 1 + rg)];
        }
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;

        for (int i = 1; i <= n; i++) {
                ll x;
                cin >> x;
                //x = rand();
                a[i] = x;
        }

	ll l = 0, r = (ll)(1e18 + 1e17);
        while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 5e5 + 7;

ll bit[maxn];
ll bitc[maxn];

ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bitc[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        //printf("===");
        while (x < maxn) {
                //printf(".");
                bitc[x] += v; x += x & (-x);
        }

}

void upd2(int x, ll v) {
        while (x < maxn) {
               bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        for (int j = 0; j <= n; j++) bitc[j] = bit[j];
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                if (s < v) {
                        if (rem < v - s) {
                                return false;
                        }
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);
        fill(bitc, bitc + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x;
                //cin >> x;
                x = rand();
                upd2(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e17);
        while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 6e5 + 7;

ll bit[maxn];
ll bitc[maxn];
ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bit[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        while (x < maxn) {
                bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        for (int j = 0; j < maxn; j++) bitc[j] = bit[j];
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                //cout << v << " ~ " << s << " : " << endl;
                if (s < v) {
                        if (rem < v - s) {
                                for (int j = 0; j < maxn; j++) bit[j] = bitc[j];
                                return false;
                        }
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        for (int j = 0; j < maxn; j++) bit[j] = bitc[j];
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);
        fill(bitc, bitc + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x; cin >> x; upd(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e17);
        while (l < r) {
		ll mid = (l + r + 1)/2;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 6e5 + 7;

ll bit[maxn];

ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bit[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        while (x < maxn) {
                bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                if (s < v) {
                        if (rem < v - s) return false;
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x; cin >> x; upd(i, x);
        }

	ll l = 0, r = (ll)1e18;
	while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 5e5 + 7;

ll bit[maxn];
ll bitc[maxn];

ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bitc[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        //printf("===");
        while (x < maxn) {
                //printf(".");
                bitc[x] += v; x += x & (-x);
        }

}

void upd2(int x, ll v) {
        while (x < maxn) {
               bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        for (int j = 0; j <= n; j++) bitc[j] = bit[j];
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                if (s < v) {
                        if (rem < v - s) {
                                return false;
                        }
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);
        fill(bitc, bitc + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x;
                cin >> x;
                //x = rand();
                upd2(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e17);
        while (l < r) {
		ll mid = (l + r + 1) >> 1;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 6e5 + 7;

ll bit[maxn];
ll bitc[maxn];
ll qry(int x) {
        ll ans = 0;
        while (x > 0) {
                ans += bit[x]; x -= x & (-x);
        }
        return ans;
}

void upd(int x, ll v) {
        while (x < maxn) {
                bit[x] += v; x += x & (-x);
        }
}

int n, rg; ll k;

bool check(ll v) {
        for (int j = 0; j <= n; j++) bitc[j] = bit[j];
        ll rem = k;
        for (int i = 1; i <= n; i++) {
                int l = max(1, i - rg), r = min(n, i + rg);
                ll s = qry(r) - qry(l - 1);
                //cout << v << " ~ " << s << " : " << endl;
                if (s < v) {
                        if (rem < v - s) {
                                for (int j = 0; j <= n; j++) bit[j] = bitc[j];
                                return false;
                        }
                        upd(r, v - s);
                        rem -= v - s;
                }
        }
        for (int j = 0; j <= n; j++) bit[j] = bitc[j];
        return true;
}

int main() {
        ios :: sync_with_stdio(false); cin.tie(0);
        cin >> n >> rg >> k;
        fill(bit, bit + maxn, 0);
        fill(bitc, bitc + maxn, 0);

        for (int i = 1; i <= n; i++) {
                ll x; cin >> x; upd(i, x);
        }

	ll l = 0, r = (ll)(1e18 + 1e17);
        while (l < r) {
		ll mid = (l + r + 1)/2;
                if (check(mid)) l = mid;
                else r = mid - 1;
        }

        cout << l << endl;
}