import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int w = in.nextInt();
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = in.nextInt();
            }
            long low = 1;
            long high = 2000000000;
            while ((high - low) > 1) {
                long mid = (high + low) / 2;
                //Does mid as a shortest flower works?
                long need = 0;
                int cur = 0;
                SegmentTreeRangeUpdate seg = new SegmentTreeRangeUpdate(ar);
                for (int i = 0; i <= (n - w); i++) {
                    long a = seg.query(i, i);
                    // out.println("i=" + i + " and a=" + a);
                    if (a < mid) {
                        seg.update(i, i + w - 1, (int) (mid - a));
                        need += (mid - a);
                    }
                }

                int maxNeed = 0;
                for (int i = (n - w + 1); i < n; i++) {
                    maxNeed = Math.max(maxNeed, (int) (mid - seg.query(i, i)));
                }
                need += maxNeed;

                if (need < 0 || need > m) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            out.println(low);
        }

    }

    static class SegmentTreeRangeUpdate {
        public long[] leaf;
        public long[] update;
        public int origSize;

        public SegmentTreeRangeUpdate(int[] list) {
            origSize = list.length;
            leaf = new long[4 * list.length];
            update = new long[4 * list.length];
            build(1, 0, list.length - 1, list);
        }

        public void build(int curr, int begin, int end, int[] list) {
            if (begin == end)
                leaf[curr] = list[begin];
            else {
                int mid = (begin + end) / 2;
                build(2 * curr, begin, mid, list);
                build(2 * curr + 1, mid + 1, end, list);
                leaf[curr] = leaf[2 * curr] + leaf[2 * curr + 1];
            }
        }

        public void update(int begin, int end, int val) {
            update(1, 0, origSize - 1, begin, end, val);
        }

        public void update(int curr, int tBegin, int tEnd, int begin, int end, int val) {
            if (tBegin >= begin && tEnd <= end)
                update[curr] += val;
            else {
                leaf[curr] += (Math.min(end, tEnd) - Math.max(begin, tBegin) + 1) * val;
                int mid = (tBegin + tEnd) / 2;
                if (mid >= begin && tBegin <= end)
                    update(2 * curr, tBegin, mid, begin, end, val);
                if (tEnd >= begin && mid + 1 <= end)
                    update(2 * curr + 1, mid + 1, tEnd, begin, end, val);
            }
        }

        public long query(int begin, int end) {
            return query(1, 0, origSize - 1, begin, end);
        }

        public long query(int curr, int tBegin, int tEnd, int begin, int end) {
            if (tBegin >= begin && tEnd <= end) {
                if (update[curr] != 0) {
                    leaf[curr] += (tEnd - tBegin + 1) * update[curr];
                    if (2 * curr < update.length) {
                        update[2 * curr] += update[curr];
                        update[2 * curr + 1] += update[curr];
                    }
                    update[curr] = 0;
                }
                return leaf[curr];
            } else {
                leaf[curr] += (tEnd - tBegin + 1) * update[curr];
                if (2 * curr < update.length) {
                    update[2 * curr] += update[curr];
                    update[2 * curr + 1] += update[curr];
                }
                update[curr] = 0;
                int mid = (tBegin + tEnd) / 2;
                long ret = 0;
                if (mid >= begin && tBegin <= end)
                    ret += query(2 * curr, tBegin, mid, begin, end);
                if (tEnd >= begin && mid + 1 <= end)
                    ret += query(2 * curr + 1, mid + 1, tEnd, begin, end);
                return ret;
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int w = in.nextInt();
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = in.nextInt();
            }
            int low = 1;
            int high = 2000000000;
            while ((high - low) > 1) {
                int mid = (high + low) / 2;
                //Does mid as a shortest flower works?
                int need = 0;
                int cur = 0;
                int[] d = new int[n + 1];
                int i = 1;
                for (; i <= (n - w + 1); i++) {
                    int x = ar[i] + cur;
                    if (x < mid) {
                        //if(mid==3) out.println((mid-x) + " when i=" + i);
                        need += mid - x;
                        cur += mid - x;
                        d[i] = mid - x;
                    }
                    if (i >= w) {
                        cur -= d[i - w + 1];
                    }
                }

                int maxNeed = 0;
                for (; i <= n; i++) {
                    int t = mid - (ar[i] + cur);
                    maxNeed = Math.max(maxNeed, t);
                    if (i >= w) {
                        cur -= d[i - w + 1];
                    }
                }
                need += maxNeed;

                if (need > m) {
                    high = mid;
                } else {
                    low = mid;
                }
            }
            out.println(low);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


//package first;
import java.util.*;
public class myfirst{
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[])
	{
		int n,m,w;
		n = sc.nextInt();
		m = sc.nextInt();
		w = sc.nextInt();
		int a[] = new int[n];
		int l = 999999999,r = -1;
		int i,j;

		for(i = 0;i<n;i++)
		{
			a[i] = sc.nextInt();
			l = Math.min(l, a[i]);
			r = Math.max(r, a[i]);
		}
		r+=m;
//		System.out.println(l);
//		System.out.println(r);
		while(r>l+1)
		{
			int mid = (l+r)/2;
			int KA[] = new int[n+1];
			int PAKAS[] = new int[n];
			for(i=0;i<n;++i)
			{
				KA[i]=0;
				if(a[i]>=mid)
				{
					PAKAS[i]=0;
				}
				else PAKAS[i]=mid-a[i];
			}
			int cur=0;
			int k=0;
			for(i=0;i<n;++i)
			{
				cur+=KA[i];
				if(cur<PAKAS[i])
				{
					k+=PAKAS[i]-cur;
					KA[Math.min(n,i+w)]=cur-PAKAS[i];
					cur=PAKAS[i];
				}
			}
			if(k<=m) l = mid;
			else r = mid;
		}
		System.out.println(l);
}
}


//package first;
import java.util.*;
public class myfirst{
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[])
	{
		int n,m,w;
		n = sc.nextInt();
		m = sc.nextInt();
		w = sc.nextInt();
		int a[] = new int[n];
		int l = 999999999,r = -1;
		int i,j;

		for(i = 0;i<n;i++)
		{
			a[i] = sc.nextInt();
			l = Math.min(l, a[i]);
			r = Math.max(r, a[i]);
		}
		r = 999999999;
//		System.out.println(l);
//		System.out.println(r);
		while(r>l+1)
		{
			int mid = (l+r)/2;
			int KA[] = new int[n+1];
			int PAKAS[] = new int[n];
			for(i=0;i<n;++i)
			{
				KA[i]=0;
				if(a[i]>=mid)
				{
					PAKAS[i]=0;
				}
				else PAKAS[i]=mid-a[i];
			}
			int cur=0;
			int k=0;
			for(i=0;i<n;++i)
			{
				cur+=KA[i];
				/*if(mid == 2)
				{
					System.out.println(cur);
				}*/
				if(cur<PAKAS[i])
				{
					k+=PAKAS[i]-cur;
					KA[Math.min(n,i+w)]=cur-PAKAS[i];
					cur=PAKAS[i];
				}
			}
			if(k<=m) l = mid;
			else r = mid;
		}
		System.out.println(l);
}
}


//package first;
import java.util.*;
public class myfirst{
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[])
	{
		int n,m,w;
		n = sc.nextInt();
		m = sc.nextInt();
		w = sc.nextInt();
		long a[] = new long[n];
		long l = 99999999999L,r = -1;
		int i,j;

		for(i = 0;i<n;i++)
		{
			a[i] = sc.nextLong();
			l = Math.min(l, a[i]);
			r = Math.max(r, a[i]);
		}
		r = 999999999999L;
//		System.out.println(l);
//		System.out.println(r);
		while(r>l+1)
		{
			long mid = (l+r)/2;
			long KA[] = new long[n+1];
			long PAKAS[] = new long[n];
			for(i=0;i<n;++i)
			{
				KA[i]=0;
				if(a[i]>=mid)
				{
					PAKAS[i]=0;
				}
				else PAKAS[i]=mid-a[i];
			}
			long cur=0;
			long k=0;
			for(i=0;i<n;++i)
			{
				cur+=KA[i];
				/*if(mid == 2)
				{
					System.out.println(cur);
				}*/
				if(cur<PAKAS[i])
				{
					k+=PAKAS[i]-cur;
					KA[Math.min(n,i+w)]=cur-PAKAS[i];
					cur=PAKAS[i];
				}
			}
			if(k<=m) l = mid;
			else r = mid;
		}
		System.out.println(l);
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Problem3 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		int n = in.nextInt(), m = in.nextInt(), w = in.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; ++i)
		{
			a[i] = in.nextInt();
		}
		long lo = 0, hi = (long) 1e10;
		while(hi - lo > 1)
		{
			long mid = (lo + hi)/2;
			if(calculateDays(a, mid, n, w) <= m)
			{
				lo = mid;
			}
			else
			{
				hi = mid;
			}
		}
		out.println(lo);
		out.close();

	}

	static long calculateDays(long[] a, long h, int n, int w)
	{
		long[] st = new long[n];
		long need = 0;
		long curAdd = 0;
		for(int i = 0; i < n; ++i)
		{
			if(w <= i)
			{
				curAdd -= st[i - w];
			}
			if(a[i] + curAdd < h)
			{
				st[i] =  h - (a[i] + curAdd);
				curAdd += st[i];
				need += st[i];
			}
		}

		return need;
	}

	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public long nextLong()
	    {
	    	return Long.parseLong(next());
	    }

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt(), w = sc.nextInt();
		int [] a = new int[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextInt();
		}
		int lo = 1, hi = (int)2e9;
		int ans = -1;
		while(lo <= hi){
			int mid = lo + ((hi-lo) >> 1);
			long cur = 0;
			int left = m;
			boolean can = true;
			long [] seg = new long[n];
			for (int i = 0; i < a.length; ++i) {
				cur -= seg[i];
				long req = Math.max(0, mid - a[i]);
				if(req > cur){
					long need = req - cur;
					if(need > left){
						can = false;
						break;
					}
					left -= need;
					cur += need;
					if(i + w < n)
						seg[i+w] += need;
				}
			}
			if(can){
				ans = mid;
				lo = mid+1;
			}
			else hi = mid-1;
		}
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

	}

}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;

public class Main {

    static int n;
    static int [] seg_ind,a;
    static long [] seg,lazy;

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;

        tk = new StringTokenizer(in.readLine());
        n = parseInt(tk.nextToken());
        int m = parseInt(tk.nextToken()),w = parseInt(tk.nextToken());

        a  = new int[n];
        seg_ind = new int[4*n];
        seg = new long[4*n];
        lazy = new long[4*n];

        tk = new StringTokenizer(in.readLine());
        for(int i=0; i<n; i++)
            a[i] = parseInt(tk.nextToken());

        build(1,0,n-1);

        for(int i=0; i<m; i++) {
            int j = seg_ind[1];

            if(j+w > n) j = n-w;

            update(1,0,n-1,j,j+w-1);
        }

        System.out.println(seg[1]);
    }

    static void build(int p,int s,int e) {
        if(s==e) {
            seg[p] = a[s];
            seg_ind[p] = s;
            return;
        }

        build(2*p,s,(s+e)/2);
        build(2*p+1,(s+e)/2+1,e);

        int x = seg[2*p] < seg[2*p+1] || (seg[2*p]==seg[2*p+1] && seg_ind[2*p]<seg_ind[2*p+1]) ? 0 : 1;

        seg[p] = seg[2*p+x];
        seg_ind[p] = seg_ind[2*p+x];
    }

    static void checkLazy(int p,int s,int e) {
        if(lazy[p]!=0) {
            seg[p] += lazy[p];
            if(s != e) {
                lazy[2*p] += lazy[p];
                lazy[2*p+1] += lazy[p];
            }
            lazy[p] = 0;
        }
    }

    static void update(int p,int s,int e,int a,int b) {
        checkLazy(p,s,e);

        if(s>=a && e<=b) {
            seg[p]++;
            if(s!=e) {
                lazy[2*p]++;
                lazy[2*p+1]++;
            }
            return;
        }

        if(s>b || e<a)
            return;

        update(2*p,s,(s+e)/2,a,b);
        update(2*p+1,(s+e)/2+1,e,a,b);

        int x = seg[2*p] < seg[2*p+1] || (seg[2*p]==seg[2*p+1] && seg_ind[2*p]<seg_ind[2*p+1]) ? 0 : 1;

        seg[p] = seg[2*p+x];
        seg_ind[p] = seg_ind[2*p+x];
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
    }
    static void solve () {
        FastReader fr =new FastReader();    PrintWriter op =new PrintWriter(System.out);

        int n =fr.nextInt() ,m =fr.nextInt() ,w =fr.nextInt() ,i ,j ,k ,o ,l ,r =(int)1e9+1 ,md ;
        int dm[] ,ar[] =new int[n+1] ;

        for (i =1 ; i<=n ; ++i)  r =Math.min(r,(ar[i] =fr.nextInt())) ;   l =1 ; r += m ;

        while (r-l > 1) {
            md =(l+r)/2 ;   j =0 ;  dm =new int[n+1] ;
            for (i =1 ; i<=n ; ++i) {
                dm[i] += dm[i-1] ;  k =ar[i]+dm[i] ;
                if (k >= md)    continue ;  o =md-k ;   j += o ;
                dm[i] =o ;   dm[Math.min(n,i+w)] -= o ;
            }
            if (j>m)    r =md-1 ;   else    l =md ;
        }
        j =0 ;  dm =new int[n+1] ;
        for (i =1 ; i<=n ; ++i) {
            dm[i] += dm[i-1] ;  k =ar[i]+dm[i] ;
            if (k >= r)    continue ;  o =r-k ; j += o ;
            dm[i] =o ;   dm[Math.min(n,i+w)] -= o ;
        }
        if (j<=m)   op.println(r) ; else    op.println(l) ;
        op.flush();    op.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br =new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st==null || (!st.hasMoreElements()))
            {
                try
                {
                    st =new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }

            }
            return st.nextToken();
        }

        String nextLine() {
            String str ="";

            try
            {
                str =br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }

            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next()) ;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
    }
    static void solve () {
        FastReader fr =new FastReader();    PrintWriter op =new PrintWriter(System.out);

        int n =fr.nextInt() ,m =fr.nextInt() ,w =fr.nextInt() ,ar[] =new int[n+1] ,l ;
        long i =1l ,j =(long)1e9+1 ,k ,o ,p ,chg[] =new long[n+2] ,ans =0l ;

        for (l =1 ; l<=n ; ++l) j =Math.min(j , (ar[l] =fr.nextInt())) ;    j += m ;

        while (i<=j) {
            k =(i+j)/2 ;    o =0l ;
            for (l =1 ; l<=n ; ++l) {
                chg[l] += chg[l-1] ;    p =chg[l]+ar[l] ;
                if (p>=k)  continue;    p =k-p ;
                chg[l] += p ;   chg[Math.min(l+w,n+1)] -= p ; o += p ;
            }
            if (o<=m) {
                ans =k ;    i =k+1 ;
            }
            else    j =k-1 ;
            for (l =0 ; l<chg.length ; ++l) chg[l] =0l ;
        }
        op.println(ans) ;    op.flush();    op.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br =new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st==null || (!st.hasMoreElements()))
            {
                try
                {
                    st =new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }

            }
            return st.nextToken();
        }

        String nextLine() {
            String str ="";

            try
            {
                str =br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }

            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next()) ;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
    }
    static void solve () {
        FastReader fr =new FastReader();    PrintWriter op =new PrintWriter(System.out);

        int n =fr.nextInt() ,ar[] =new int[n+1] ,m =fr.nextInt() ,w =fr.nextInt() ,i ;
        long dm[] ,j ,k ,l ,o ,r =(int)1e9+1 ,md ;

        for (i =1 ; i<=n ; ++i)  r =Math.min(r,(ar[i] =fr.nextInt())) ;   l =1 ; r += m ;

        while (r-l > 1) {
            md =(l+r)/2 ;   j =0 ;  dm =new long[n+1] ;
            for (i =1 ; i<=n ; ++i) {
                dm[i] += dm[i-1] ;  k =ar[i]+dm[i] ;
                if (k >= md)    continue ;  o =md-k ;   j += o ;
                dm[i] =o ;   dm[Math.min(n,i+w)] -= o ;
            }
            if (j>m)    r =md-1 ;   else    l =md ;
        }
        j =0 ;  dm =new long[n+1] ;
        for (i =1 ; i<=n ; ++i) {
            dm[i] += dm[i-1] ;  k =ar[i]+dm[i] ;
            if (k >= r)    continue ;  o =r-k ; j += o ;
            dm[i] =o ;   dm[Math.min(n,i+w)] -= o ;
        }
        if (j<=m)   op.println(r) ; else    op.println(l) ;
        op.flush();    op.close();
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br =new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st==null || (!st.hasMoreElements()))
            {
                try
                {
                    st =new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }

            }
            return st.nextToken();
        }

        String nextLine() {
            String str ="";

            try
            {
                str =br.readLine();
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }

            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next()) ;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class Present2 {
    void solve() {
        int n = in.nextInt(), m = in.nextInt(), w = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();

        int lb = 1, ub = (int) (1e9 + 1e5 + 5);
        while (ub - lb > 1) {
            int h = (lb + ub) / 2;
            int open = 0, tot = 0;
            int[] cnt = new int[n];
            for (int i = 0; i < n; i++) {
                if (i - w >= 0) open -= cnt[i - w];
                int delta = Math.max(0, h - a[i] - open);
                cnt[i] = delta;
                open += delta;
                tot += delta;
                if (tot > m) break;
            }
            if (tot <= m) lb = h;
            else ub = h;
        }

        out.println(lb);
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Present2().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class Present {
    void solve() {
        int n = in.nextInt(), m = in.nextInt(), w = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();

        int lb = 1, ub = (int) (1e9 + 1e5 + 5);
        while (ub - lb > 1) {
            int h = (lb + ub) / 2;

            int open = 0, cnt = 0;
            Queue<Integer> qu = new LinkedList<>();
            for (int i = 0; i < n; i++) {
                while (!qu.isEmpty() && qu.peek() == i) {
                    open--;
                    qu.poll();
                }
                if (a[i] + open >= h) continue;
                int delta = h - a[i] - open;
                open += delta;
                cnt += delta;
                if (cnt > m) break;
                for (int j = 0; j < delta; j++) qu.offer(i + w);
            }

            if (cnt <= m) lb = h;
            else ub = h;
        }

        out.println(lb);
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Present().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int w=Integer.parseInt(st.nextToken());
        long a[]=new long[n];
        st=new StringTokenizer(br.readLine());
        long b[]=new long[n];
        for(int i=0;i<n;i++)
        {
            a[i]=Long.parseLong(st.nextToken());
            b[i]=a[i];
        }
        for(int i=1;i<n;i++)
            a[i]+=a[i-1];
        for(int i=n-1;i>=w;i--)
            a[i]-=a[i-w];
        for(int i=0;i<m;i++)
        {
            long min=Long.MAX_VALUE;
            int min_i=0;
            for(int ii=0;ii<n;ii++)
            {
                if(b[ii]<min)
                {
                    min=b[ii];
                    min_i=ii;
                }
            }
            int idx=(int)Math.min(min_i+w-1,n-1);
            long count=w;
            min=Long.MAX_VALUE;
            for(int j=idx;j>=w-1;j--)
            {
                if(min>a[j])
                {
                    min=a[j];
                    min_i=j;
                }
            }
            for(int j=0;j<w;j++)
            {
                a[min_i-j]+=count;
                count--;
                b[min_i-j]++;
            }
        }
        long min=Long.MAX_VALUE;
        for(int i=0;i<n;i++)
            if(min>b[i])
                min=b[i];
        System.out.print(min);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static int n,m,w;
    static long arr[];
    public static boolean check(long mid)
    {
        long s[]=new long[n];
        long a=0,t=0;
        for(int i=0;i<n;i++)
        {
            if(i>=w)
                a-=s[i-w];
            if(arr[i]+a<mid)
            {
                s[i]=mid-a-arr[i];
                t+=s[i];
                a+=s[i];
            }
        }
        return t<=m;
    }
    public static void main(String args[]) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m=Integer.parseInt(st.nextToken());
        w=Integer.parseInt(st.nextToken());
        st=new StringTokenizer(br.readLine());
        arr=new long[n];
        for(int i=0;i<n;i++)
            arr[i]=Integer.parseInt(st.nextToken());
        long l=0,r=1000100000;
        while(l+1<r)
        {
            long mid=(l+r)/2;
            if(check(mid)) l=mid;
            else r = mid;
        }
        System.out.print(l);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static int n,m,w;
    static long arr[];
    public static boolean check(long mid)
    {
        long s[]=new long[n];
        long a=0,t=0;
        for(int i=0;i<n;i++)
        {
            if(i>=w)
                a-=s[i-w];
            if(arr[i]+a<mid)
            {
                s[i]=mid-a-arr[i];
                t+=s[i];
                a+=s[i];
            }
        }
        return t<=m;
    }
    public static void main(String args[]) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m=Integer.parseInt(st.nextToken());
        w=Integer.parseInt(st.nextToken());
        st=new StringTokenizer(br.readLine());
        arr=new long[n];
        for(int i=0;i<n;i++)
            arr[i]=Long.parseLong(st.nextToken());
        long l=0,r=1000100000;
        while(l+1<r)
        {
            long mid=(l+r)/2;
            if(check(mid)) l=mid;
            else r = mid;
        }
        System.out.print(l);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int w=Integer.parseInt(st.nextToken());
        long a[]=new long[n];
        st=new StringTokenizer(br.readLine());
        long b[]=new long[n];
        for(int i=0;i<n;i++)
        {
            a[i]=Long.parseLong(st.nextToken());
            b[i]=a[i];
        }
        for(int i=1;i<n;i++)
            a[i]+=a[i-1];
        for(int i=w;i<n;i++)
            a[i]-=a[i-w];
        for(int i=0;i<m;i++)
        {
            long min=Long.MAX_VALUE;
            int min_i=0;
            for(int j=w-1;j<n;j++)
            {
                if(min>a[j])
                {
                    min=a[j];
                    min_i=j;
                }
            }
            long count=w;
            for(int j=0;j<w;j++)
            {
                a[min_i-j]+=count;
                count--;
                b[min_i-j]++;
            }
        }
        long min=Long.MAX_VALUE;
        for(int i=0;i<n;i++)
            if(min>b[i])
                min=b[i];
        System.out.print(min);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int w=Integer.parseInt(st.nextToken());
        long a[]=new long[n];
        st=new StringTokenizer(br.readLine());
        long b[]=new long[n];
        for(int i=0;i<n;i++)
        {
            a[i]=Long.parseLong(st.nextToken());
            b[i]=a[i];
        }
        for(int i=1;i<n;i++)
            a[i]+=a[i-1];
        for(int i=n-1;i>=w;i--)
            a[i]-=a[i-w];
        for(int i=0;i<m;i++)
        {
            long min=Long.MAX_VALUE;
            int min_i=0;
            for(int ii=0;ii<n;ii++)
            {
                if(b[ii]<min)
                {
                    min=b[ii];
                    min_i=ii;
                }
            }
            int idx=(int)Math.min(min_i+w-1,n-1);
            long count=w;
            min=Long.MAX_VALUE;
            for(int j=0;j<w;j++)
            {
                if(min>a[idx-j])
                {
                    min=a[idx-j];
                    min_i=idx-j;
                }
            }
            for(int j=0;j<w;j++)
            {
                a[min_i-j]+=count;
                count--;
                b[min_i-j]++;
            }
        }
        long min=Long.MAX_VALUE;
        for(int i=0;i<n;i++)
            if(min>b[i])
                min=b[i];
        System.out.print(min);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static int n,m,w;
    static long arr[];
    public static boolean check(long mid)
    {
        long s[]=new long[n];
        long a=0,t=0;
        for(int i=0;i<n;i++)
        {
            if(i>=w)
                a-=s[i-w];
            if(arr[i]+a<mid)
            {
                s[i]=mid-a-arr[i];
                t+=s[i];
                a+=s[i];
            }
        }
        return t<=m;
    }
    public static void main(String args[]) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m=Integer.parseInt(st.nextToken());
        w=Integer.parseInt(st.nextToken());
        st=new StringTokenizer(br.readLine());
        arr=new long[n];
        for(int i=0;i<n;i++)
            arr[i]=Long.parseLong(st.nextToken());
        long l=0,r=1000100001l;

        while(l+1<r)
        {
           // System.out.println(l+" "+r);
            long mid=(l+r)/2l;
            if(check(mid)) l=mid;
            else r = mid;
        }
        System.out.print(l);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        int w=Integer.parseInt(st.nextToken());
        long a[]=new long[n];
        st=new StringTokenizer(br.readLine());
        long b[]=new long[n];
        for(int i=0;i<n;i++)
        {
            a[i]=Long.parseLong(st.nextToken());
            b[i]=a[i];
        }
        for(int i=1;i<n;i++)
            a[i]+=a[i-1];
        for(int i=n-1;i>=w;i--)
            a[i]-=a[i-w];
        for(int i=0;i<m;i++)
        {
            long min=Long.MAX_VALUE;
            int min_i=0;
            for(int j=w-1;j<n;j++)
            {
                if(min>a[j])
                {
                    min=a[j];
                    min_i=j;
                }
            }
            long count=w;
            for(int j=0;j<w;j++)
            {
                a[min_i-j]+=count;
                count--;
                b[min_i-j]++;
            }
        }
        long min=Long.MAX_VALUE;
        for(int i=0;i<n;i++)
            if(min>b[i])
                min=b[i];
        System.out.print(min);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static int n,m,w;
    static long arr[];
    public static boolean check(long mid)
    {
        long s[]=new long[n];
        long a=0,t=0;
        for(int i=0;i<n;i++)
        {
            if(i>w)
                a-=s[i-w];
            if(arr[i]+a<mid)
            {
                s[i]=mid-a-arr[i];
                t+=s[i];
                a+=s[i];
            }
        }
        return t<=m;
    }
    public static void main(String args[]) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m=Integer.parseInt(st.nextToken());
        w=Integer.parseInt(st.nextToken());
        st=new StringTokenizer(br.readLine());
        arr=new long[n];
        for(int i=0;i<n;i++)
            arr[i]=Long.parseLong(st.nextToken());
        long l=0,r=1000100001l;

        while(l+1<r)
        {
           // System.out.println(l+" "+r);
            long mid=(l+r)/2l;
            if(check(mid)) l=mid;
            else r = mid;
        }
        System.out.print(l);
    }
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF460C extends PrintWriter {
	CF460C() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF460C o = new CF460C(); o.main(); o.flush();
	}

	int n, m, w;
	int[] aa, dd;
	boolean check(int b) {
		dd[0] = aa[0];
		for (int i = 1; i < n; i++)
			dd[i] = aa[i] - aa[i - 1];
		int a = 0, m_ = 0;
		for (int i = 0; i < n; i++) {
			a += dd[i];
			if (a < b) {
				if (m < m_ + b - a)
					return false;
				m_ += b - a;
				if (i + w < n)
					dd[i + w] -= b - a;
				a = b;
			}
		}
		return true;
	}
	void main() {
		n = sc.nextInt();
		m = sc.nextInt();
		w = sc.nextInt();
		aa = new int[n];
		dd = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		int amin = 0x3f3f3f3f;
		for (int i = 0; i < n; i++)
			amin = Math.min(amin, aa[i]);
		int lower = amin, upper = amin + m + 1;
		while (upper - lower > 1) {
			int a = (lower + upper) / 2;
			if (check(a))
				lower = a;
			else
				upper = a;
		}
		println(lower);
	}
}


//package cf262;

import java.util.*;
import java.io.*;

public class C {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int w = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long l = 0;
		long r = (long) 1e15;
		while ((r - l) > 1) {
			long mid = (r + l) / 2;
			long cur = 0;
			long countWash = 0;
			long[] finish = new long[n + 1];
			for (int i = 0; i < n; i++) {
				if (mid - (a[i] + cur) > 0) {
					countWash += mid - (a[i] + cur);
					finish[Math.min(n, i + w)] = mid - (a[i] + cur);
				}
			}
			if (countWash <= m) {
				l = mid;
			} else {
				r = mid;
			}
		}
		System.out.println(l);
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new C().run();
	}
}


//package cf262;

import java.util.*;
import java.io.*;

public class C {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int w = in.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long l = 0;
		long r = (long) 1e15;
		while ((r - l) > 1) {
			long mid = (r + l) / 2;

			long cur = 0;
			long countWash = 0;
			long[] finish = new long[n + 1];
			for (int i = 0; i < n; i++) {
				cur -= finish[i];
				if ((mid - (a[i] + cur)) > 0) {
					countWash += (mid - (a[i] + cur));
					finish[Math.min(n, i + w)] = (mid - (a[i] + cur));
					cur += (mid - (a[i] + cur));
				}
			}
			if (countWash <= m) {
				l = mid;
			} else {
				r = mid;
			}
		}
		System.out.println(l);
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new C().run();
	}
}


//package cf262;

import java.util.*;
import java.io.*;

public class C {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int w = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long l = 0;
		long r = (long) 1e15;
		while ((r - l) > 1) {
			long mid = (r + l) / 2;
			long cur = 0;
			long countWash = 0;
			long[] finish = new long[n + 1];
			for (int i = 0; i < n; i++) {
				cur -= finish[i];
				if (mid - (a[i] + cur) > 0) {
					countWash += mid - (a[i] + cur);
					finish[Math.min(n, i + w)] = mid - (a[i] + cur);
					cur += mid - (a[i] + cur);
				}
			}
			if (countWash <= m) {
				l = mid;
			} else {
				r = mid;
			}
		}
		System.out.println(l);
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new C().run();
	}
}


//package cf262;

import java.util.*;
import java.io.*;

public class C {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int m = in.nextInt();
		int w = in.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		long l = 0;
		long r = (long) 1e11;
		while ((r - l) > 1) {
			long mid = (r + l) / 2;

			long cur = 0;
			long countWash = 0;
			long[] finish = new long[n + 1];
			for (int i = 0; i < n; i++) {
				cur -= finish[i];
				if ((mid - (a[i] + cur)) > 0) {
					countWash += (mid - (a[i] + cur));
					finish[Math.min(n, i + w)] = (mid - (a[i] + cur));
					cur += (mid - (a[i] + cur));
				}
			}
			if (countWash <= m) {
				l = mid;
			} else {
				r = mid;
			}
		}
		System.out.println(l);
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new C().run();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int n=sc.nextInt(),m=sc.nextInt(),w=sc.nextInt();
        long[] arr=new long[n];
        long min=0;
        for(int i=0;i<n;i++)arr[i]=sc.nextInt();

        int[] sum=new int[n+w+1];
        int l=0,r=(int)1e9,ans=0;
        while(l<=r){
            Arrays.fill(sum,0);
            int mid=l+(r-l)/2;
            long temp=0;
            for(int i=0;i<n && temp<=m;i++){
                if(i>0)sum[i]+=sum[i-1];
                if(arr[i]+sum[i]<mid){
                    temp+=mid-(arr[i]+sum[i]);
                    sum[i+w]-=mid-(arr[i]+sum[i]);
                    sum[i]+=mid-(arr[i]+sum[i]);
                }
            }
            if(temp<=m){
                ans=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        System.out.println(ans);
    }

}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int mod=(int)1e9+7;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int n=sc.nextInt(),m=sc.nextInt(),w=sc.nextInt();
        long[] arr=new long[n];
        long min=0;
        for(int i=0;i<n;i++)arr[i]=sc.nextInt();

        int[] sum=new int[n+w+1];
        long l=0,r=(int)1e12,ans=0;
        while(l<=r){
            Arrays.fill(sum,0);
            long mid=l+(r-l)/2;
            long temp=0;
            for(int i=0;i<n && temp<=m;i++){
                if(i>0)sum[i]+=sum[i-1];
                if(arr[i]+sum[i]<mid){
                    temp+=mid-(arr[i]+sum[i]);
                    sum[i+w]-=mid-(arr[i]+sum[i]);
                    sum[i]+=mid-(arr[i]+sum[i]);
                }
            }
            if(temp<=m){
                ans=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        System.out.println(ans);
    }

}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class E {
	static int n,m,w,x;
	static int [] a,inc;
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out,true);

		n=sc.nextInt();
		m=sc.nextInt();
		w=sc.nextInt();

		inc=new int [n];

		a=new int [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();

		int start=1,end=(int)(1e9+1e5),ans=1;
		while(start<=end){
			int mid=((start+end)>>1);
			if(f(mid)){
				ans=mid;
				start=mid+1;
			}else
				end=mid-1;
		}

		pw.println(ans);

		pw.flush();
		pw.close();
	}

	public static boolean f(int y){
		x=y;
		return cnt(0,0)<=m;
	}

	public static int cnt(int i,int extra){
		if(i==n)
			return 0;

		int ans=0;
		if(a[i]+extra<x){
			int tmp=x-(a[i]+extra);

			if(i+w-1<n)
				inc[i+w-1]=tmp;

			extra+=tmp;
			ans+=tmp;
		}
		extra-=inc[i];
		ans+=cnt(i+1,extra);

		return ans;
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class E {
	static int n,m,w,x;
	static int [] a,inc;
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out,true);

		n=sc.nextInt();
		m=sc.nextInt();
		w=sc.nextInt();

		a=new int [n];
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			min=Math.min(min, a[i]);
		}

		int start=min,end=(int)(1e9+1e5),ans=min;
		while(start<=end){
			int mid=((start+end)>>1);
			if(f(mid)){
				ans=mid;
				start=mid+1;
			}else
				end=mid-1;
		}

		pw.println(ans);
		pw.flush();
		pw.close();
	}

	public static boolean f(int y){
		x=y;
		inc=new int [n];
		return cnt(0,0)<=m;
	}

	public static long cnt(int i,int extra){
		if(i==n)
			return 0;

		long ans=0;
		if(a[i]+extra<x){
			int tmp=x-(a[i]+extra);

			if(i+w-1<n)
				inc[i+w-1]=tmp;

			extra+=tmp;
			ans+=tmp;
		}
		extra-=inc[i];
		ans+=cnt(i+1,extra);

		return ans;
	}

	static class MyScanner {
	      BufferedReader br;
	      StringTokenizer st;

	      public MyScanner() {
	         br = new BufferedReader(new InputStreamReader(System.in));
	      }

	      String next() {
	          while (st == null || !st.hasMoreElements()) {
	              try {
	                  st = new StringTokenizer(br.readLine());
	              } catch (IOException e) {
	                  e.printStackTrace();
	              }
	          }
	          return st.nextToken();
	      }

	      int nextInt() {
	          return Integer.parseInt(next());
	      }

	      long nextLong() {
	          return Long.parseLong(next());
	      }

	      double nextDouble() {
	          return Double.parseDouble(next());
	      }

	      String nextLine(){
	          String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	      }

	   }
}


import java.util.*;
import java.io.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int w = sc.nextInt();
		long[] arr= new long[n];
		for(int i  = 0; i < n; i++){
			arr[i] = sc.nextLong();
		}

		long l = 0, r = 20000000000L;
		while(l < r){
			long mid = l+(r-l+1)/2L;
			if(f(m, w, mid, arr)){
				l = mid;
			}
			else{
				r = mid - 1;
			}
		}

		System.out.println(l);

		//System.out.println(f(m, w, 1, arr));
	}

	static boolean f(long m, int w, long mid, long[] a){
		int n = a.length;
		long[] req =new long[n];
		for(int i = 0; i < n; i++){
			req[i] = Math.max(0, mid - a[i]);
		}

		long[] offset = new long[n];
		int cur = 0;
		for(int i = 0; i < n; i++){
			cur = cur + Math.round(offset[i]);
			if(req[i]-cur > 0){
				m = m - (int)Math.round(req[i]-cur);
				if(m < 0)
					return false;
				if(i+w < n){
					offset[i+w] -= (req[i]-cur);
				}
				cur = cur + (int)Math.round(req[i]-cur);
			}
		}

		return true;
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Queue;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 2e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int add = 0;
            Queue<Integer> q = new LinkedList<>(), values = new LinkedList<>();
            for (int i = 0; i < arr.length; i++) {
                if (!q.isEmpty() && i - q.peek() >= segLength) {
                    add -= values.poll();
                    q.poll();
                }
                if (arr[i] + add < mid) {
                    daysLeft -= mid - (arr[i] + add);
                    values.add(mid - (arr[i] + add));
                    add += mid - (arr[i] + add);
                    q.add(i);
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int l = 0, h = (int) 2e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int idx = -(int) 1e9;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid && i - idx >= segLength) {
                    daysLeft -= mid - arr[i];
                    idx = i;
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 2e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = (h + l) >> 1;
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int idx = (int) 1e9;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid && i - idx <= segLength) {
                    daysLeft -= mid - arr[i];
                    idx = i;
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 10;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = (h + l) >> 1;
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int idx = (int) 1e9;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid && i - idx <= segLength) {
                    daysLeft -= mid - arr[i];
                    idx = i;
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 2e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr2, int daysLeft, int segLength) {
            int idx = -(int) 1e9;
            int[] arr = arr2.clone();
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid) {
                    daysLeft -= mid - arr[i];
                    for (int j = i + 1; j < Math.min(arr.length, i + segLength); j++)
                        arr[j] += mid - arr[i];
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int l = 0, h = (int) 1e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = (h + l) >> 1;
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int idx = (int) 1e9;
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid && i - idx > segLength) {
                    daysLeft -= mid - arr[i];
                    idx = i;
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 1e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr2, int daysLeft, int segLength) {
            int start = 0;
            int[] arr = arr2.clone();
            ArrayList<Integer> idx = new ArrayList<>(), values = new ArrayList<>();
            loop:
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid) {
                    for (int j = start; j < idx.size() && arr[i] < mid; j++) {
                        if (i - idx.get(j) >= segLength) {
                            start++;
                            continue;
                        } else
                            arr[i] += values.get(j);
                    }
                    if (arr[i] < mid) {
                        daysLeft -= mid - arr[i];
                        idx.add(i);
                        values.add(mid - arr[i]);
                    }
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Queue;
import java.io.FileReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 2e9;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr, int daysLeft, int segLength) {
            int idx = -(int) 1e9;
            Queue<Integer> q = new LinkedList<>(), pq = new LinkedList<>();
            loop:
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid) {
                    while (!pq.isEmpty()) {
                        if (i - pq.peek() < segLength && arr[i] + q.peek() >= mid)
                            continue loop;
                        else {
                            pq.poll();
                            q.peek();
                        }
                    }
                    daysLeft -= mid - arr[i];
                    q.add(mid - arr[i]);
                    pq.add(i);
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), daysLeft = sc.nextInt(), segLength = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            int l = 0, h = (int) 1e9 + (int) 1e6;
            int max = Integer.MIN_VALUE;
            while (l <= h) {
                int mid = l + ((h - l) >> 1);
                if (valid(mid, arr, daysLeft, segLength)) {
                    max = mid;
                    l = mid + 1;
                } else
                    h = mid - 1;
            }
            pw.println(max);
        }

        private boolean valid(int mid, int[] arr2, int daysLeft, int segLength) {
            int start = 0;
            int[] arr = arr2.clone();
            ArrayList<Integer> idx = new ArrayList<>(), values = new ArrayList<>();
            loop:
            for (int i = 0; i < arr.length; i++) {
                if (arr[i] < mid) {
                    for (int j = start; j < idx.size() && arr[i] < mid; j++) {
                        if (i - idx.get(j) >= segLength) {
                            start++;
                            continue;
                        } else
                            arr[i] += values.get(j);
                    }
                    if (arr[i] < mid) {
                        daysLeft -= mid - arr[i];
                        idx.add(i);
                        values.add(mid - arr[i]);
                    }
                }
                if (daysLeft < 0)
                    return false;
            }
            return true;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

public class code
{
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[])throws IOException
	{
        FastReader scn = new FastReader();

        int n = scn.nextInt();
        int m = scn.nextInt();
        int w = scn.nextInt();

        int[] list = new int[n];
        for(int i = 0; i < n; i++)
            list[i] = scn.nextInt();

        int r = Integer.MAX_VALUE;
        int l = 0;

        int ans = 0;
        while(l<=r)
        {
            int middle = (r + l)/2;

            if(possible(list, middle, n, m, w))
            {
                ans = middle;
                l = middle + 1;
            }
            else
            {
                r = middle - 1;
            }
        }

        System.out.println(ans);
	}

    public static boolean possible(int[] list, int value, int n, int m, int w)
    {
        int cost = 0;
        int offset = 0;

        int[] list_adds = new int[n];
        for(int i = n - 1; i >= 0; i--)
        {
            offset = offset + list_adds[i];

            if(list[i] + offset < value )
            {
                int addition = value - list[i] - offset;

                cost = cost + addition;

                list_adds[i] = addition;
                if( i - w >= 0)
                    list_adds[i-w] = -addition;

                offset = offset + addition;
            }

            if(cost > m)
                return false;
        }
        return true;
    }

    public static long inverseModulo(long a, long P)
    {
        return powerModulo(a, P-2, P);
    }

    public static long powerModulo(long a, long p, long m)
    {
        if(p==0)
            return 1;

        long temp = powerModulo(a, p/2, m);
        temp = (temp * temp)%m;
        if(p%2 == 0)
            return temp;
        else
            return (a * temp)%m;

    }
}

class Node implements Comparable<Node>
{
    int index;
    int degree;
    int xor_value;

    public Node(int index, int degree, int xor_value)
    {
        this.index = index;
        this.degree = degree;
        this.xor_value = xor_value;
    }

    public int compareTo(Node n)
    {
        if(this.degree < n.degree)
            return -1;
        else if(this.degree == n.degree)
            return 0;
        else return 1;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt(), m = sc.nextInt(), w = sc.nextInt();

		long [] arr = new long [n];
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();

		long lo = 0, hi = (long)1e10, best = 0;

		long [] add = new long [n];

		for (int cnt = 0; cnt <= 200; cnt++) {
			long mid = lo + ((hi - lo) >> 1);

			for (int i = 0; i < n; i++)
				add[i] = Math.max(0, mid - arr[i]);

			long [] end = new long[n];
			boolean ok = true;

			long cur = 0;
			int left = m;
			for (int i = 0; i < n; i++) {
				cur -= end[i];
				if (add[i] > cur) {
					long needed = add[i] - cur;
					if (needed > left) {
						ok = false;
					}
					else {
						left -= needed;
						if (i + w < n) end[i + w] += needed;
						cur += needed;
					}
				}
			}

			if (ok) {
				best = mid;
				lo = Math.min(hi, mid + 1);
			}
			else hi = Math.max(lo, mid - 1);
		}

		out.println(best);
		out.flush();
		out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public boolean nextEmpty() throws IOException
		{
			String s = nextLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cunbidun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CPresent solver = new CPresent();
        solver.solve(1, in, out);
        out.close();
    }

    static class CPresent {
        private InputReader in;
        private PrintWriter out;
        private int n;
        private int w;
        private long m;
        private long[] a;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            n = in.nextInt();
            m = in.nextInt();
            w = in.nextInt();
            a = in.nextLongArray(n, 1);
            long l = ArrayAlgorithm.getMin(a, 1, n);
            long r = l + m;
            while (l != r) {
                if (l == (r - 1)) {
                    if (ch(r)) l = r;
                    break;
                }
                long mid = (l + r) >> 1;
                if (ch(mid)) l = mid;
                else r = mid - 1;
            }
            out.println(l);
        }

        private boolean ch(long mid) {
            STRangeAddSumLong st = new STRangeAddSumLong(n, a);
            long res = 0;
            for (int i = 1; i <= n; i++) {
                long tmp = st.getSum(i, i);
                if (tmp < mid) {
                    st.update(i, MaxMin.Min(n, i + w - 1), mid - tmp);
                    res += mid - tmp;
                }
            }
            return res <= m;
        }

    }

    static class ArrayAlgorithm {
        public static long getMin(long[] array, int stIndex, int enIndex) {
            long min = array[stIndex];
            for (int i = stIndex; i <= enIndex; i++) {
                min = MaxMin.Min(min, array[i]);
            }
            return min;
        }

    }

    static class STRangeAddSumLong {
        private long[] segment;
        private long[] lazy;
        private long[] array;
        private int N;

        public STRangeAddSumLong(int n) {
            segment = new long[4 * n];
            lazy = new long[4 * n];
            N = n;
        }

        public STRangeAddSumLong(int n, long[] inputArray) {
            segment = new long[4 * n];
            lazy = new long[4 * n];
            this.array = inputArray;
            N = n;
            buildTree(1, 1, N);
        }

        private void buildTree(int i, int l, int r) {
            if (l > r) return;
            if (l == r) {
                segment[i] = array[l];
                return;
            }
            int m = (l + r) >> 1;
            buildTree(i * 2, l, m);
            buildTree(i * 2 + 1, m + 1, r);
            segment[i] = segment[i * 2] + segment[i * 2 + 1];
        }

        private void trueVal(int i, int l, int r) {
            if (lazy[i] == 0) return;
            segment[i] += lazy[i] * (r - l + 1);
            if (l != r) {
                lazy[i * 2] += lazy[i];
                lazy[i * 2 + 1] += lazy[i];
            }
            lazy[i] = 0;
        }

        public void update(int l, int r, long val) {
            update(1, 1, N, l, r, val);
        }

        private void update(int i, int l, int r, int L, int R, long val) {
            trueVal(i, l, r);
            if (l > r || l > R || r < L) return;
            if (l >= L && r <= R) {
                segment[i] += val * (r - l + 1);
                if (l != r) {
                    lazy[i * 2] += val;
                    lazy[i * 2 + 1] += val;
                }
                return;
            }
            int m = (l + r) >> 1;
            update(i * 2, l, m, L, R, val);
            update(i * 2 + 1, m + 1, r, L, R, val);
            segment[i] = segment[i * 2] + segment[i * 2 + 1];
        }

        public long getSum(int l, int r) {
            return getSum(1, 1, N, l, r);
        }

        private long getSum(int i, int l, int r, int L, int R) {
            trueVal(i, l, r);
            if (l > r || l > R || r < L) return 0;
            if (l >= L && r <= R) return segment[i];
            int m = (l + r) >> 1;
            return getSum(i * 2, l, m, L, R) + getSum(i * 2 + 1, m + 1, r, L, R);
        }

    }

    static class InputReader extends InputStream {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long[] nextLongArray(int length, int stIndex) {
            long[] arr = new long[length + stIndex];
            for (int i = stIndex; i < stIndex + length; i++)
                arr[i] = nextLong();
            return arr;
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class MaxMin {
        public static <T extends Comparable<T>> T Min(T x, T y) {
            T min = x;
            if (y.compareTo(min) < 0) min = y;
            return min;
        }

    }
}