#include <iterator>
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
map<ll, ll> :: iterator it, pr;
map<ll, ll> m;
ll n, k, i, a[100100], mx = 0;
int main() {
freopen("repair.in", "r", stdin);
freopen("repair.out", "w", stdout);
scanf("%I64d%I64d", &n, &k);
for(i = 0; i < n; i ++){
scanf("%I64d", a + i);
m[a[i]] ++; mx = max(mx, a[i]);
}
for(it = m.begin(); it != m.end(); it ++){
if(it == m.begin()){
pr = m.begin();
continue;
}
else{
ll dif = it -> first - pr -> first;
ll kol = pr -> second;
ll req = dif * kol;
ll can = min(k, req);
ll lev = can / kol;
ll ost = can % kol;
if(k > can){
m[it -> first] += kol;
m[pr -> first] = 0;
k -= can; pr = it;
}
else{
printf("%I64d", lev + pr -> first);
return 0;
}
}
}
printf("%I64d", mx + k / n);
return 0;
}
I2luY2x1ZGUgPGl0ZXJhdG9yPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxtYXA+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CgptYXA8bGwsIGxsPiA6OiBpdGVyYXRvciBpdCwgcHI7Cm1hcDxsbCwgbGw+IG07CgpsbCBuLCBrLCBpLCBhWzEwMDEwMF0sIG14ID0gMDsKaW50IG1haW4oKSB7CiAgICBmcmVvcGVuKCJyZXBhaXIuaW4iLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oInJlcGFpci5vdXQiLCAidyIsIHN0ZG91dCk7CgogICAgc2NhbmYoIiVJNjRkJUk2NGQiLCAmbiwgJmspOwogICAgZm9yKGkgPSAwOyBpIDwgbjsgaSArKyl7CiAgICAgICAgc2NhbmYoIiVJNjRkIiwgYSArIGkpOwogICAgICAgIG1bYVtpXV0gKys7IG14ID0gbWF4KG14LCBhW2ldKTsKICAgIH0KICAgIGZvcihpdCA9IG0uYmVnaW4oKTsgaXQgIT0gbS5lbmQoKTsgaXQgKyspewogICAgICAgIGlmKGl0ID09IG0uYmVnaW4oKSl7CiAgICAgICAgICAgIHByID0gbS5iZWdpbigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgbGwgZGlmID0gaXQgLT4gZmlyc3QgLSBwciAtPiBmaXJzdDsKICAgICAgICAgICAgbGwga29sID0gcHIgLT4gc2Vjb25kOwogICAgICAgICAgICBsbCByZXEgPSBkaWYgKiBrb2w7CiAgICAgICAgICAgIGxsIGNhbiA9IG1pbihrLCByZXEpOwogICAgICAgICAgICBsbCBsZXYgPSBjYW4gLyBrb2w7CiAgICAgICAgICAgIGxsIG9zdCA9IGNhbiAlIGtvbDsKCiAgICAgICAgICAgIGlmKGsgPiBjYW4pewogICAgICAgICAgICAgICAgbVtpdCAtPiBmaXJzdF0gKz0ga29sOwogICAgICAgICAgICAgICAgbVtwciAtPiBmaXJzdF0gPSAwOwogICAgICAgICAgICAgICAgayAtPSBjYW47IHByID0gaXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgIHByaW50ZigiJUk2NGQiLCBsZXYgKyBwciAtPiBmaXJzdCk7CiAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHByaW50ZigiJUk2NGQiLCBteCArIGsgLyBuKTsKICAgIHJldHVybiAwOwp9Cg==