#include <iostream>
#include <algorithm>
using namespace std;
long N, K;
long* A;
long sum_depending_on_mid(int m) {
long summ = 0;
for (int i = 0; i <= N - 1 ; i++) {
if(A[i] > m) summ += A[i] - m;
}
return summ;
}
int main() {
cin >> N >> K;
A = new long[N];
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N);
long low = 0;
long high = A[N - 1];
long mid = 0;
while (low != high and sum_depending_on_mid(mid = (low + high) / 2) != K) {
long past_low = low;
long past_high = high;
if (sum_depending_on_mid(mid) < K) {
high = mid;
} else low = mid;
if (past_low == low and past_high == high) {
cout << mid;
return 0;
}
}
cout << mid;
delete[] A;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKbG9uZyBOLCBLOwpsb25nKiBBOwoKbG9uZyBzdW1fZGVwZW5kaW5nX29uX21pZChpbnQgbSkgewoJbG9uZyBzdW1tID0gMDsKCWZvciAoaW50IGkgPSAwOyBpIDw9IE4gLSAxIDsgaSsrKSB7CgkJaWYoQVtpXSA+IG0pIHN1bW0gKz0gQVtpXSAtIG07Cgl9CglyZXR1cm4gc3VtbTsKfQoKaW50IG1haW4oKSB7CgljaW4gPj4gTiA+PiBLOwoJQSA9IG5ldyBsb25nW05dOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspIHsKCQljaW4gPj4gQVtpXTsKCX0KCXNvcnQoQSwgQSArIE4pOwoJbG9uZyBsb3cgPSAwOwoJbG9uZyBoaWdoID0gQVtOIC0gMV07Cglsb25nIG1pZCA9IDA7Cgl3aGlsZSAobG93ICE9IGhpZ2ggYW5kIHN1bV9kZXBlbmRpbmdfb25fbWlkKG1pZCA9IChsb3cgKyBoaWdoKSAvIDIpICE9IEspIHsKCQlsb25nIHBhc3RfbG93ID0gbG93OwoJCWxvbmcgcGFzdF9oaWdoID0gaGlnaDsKCQlpZiAoc3VtX2RlcGVuZGluZ19vbl9taWQobWlkKSA8IEspIHsKCQkJaGlnaCA9IG1pZDsKCQl9IGVsc2UgbG93ID0gbWlkOwoJCWlmIChwYXN0X2xvdyA9PSBsb3cgYW5kIHBhc3RfaGlnaCA9PSBoaWdoKSB7CgkJCWNvdXQgPDwgbWlkOwoJCQlyZXR1cm4gMDsKCQl9Cgl9Cgljb3V0IDw8IG1pZDsKCWRlbGV0ZVtdIEE7Cn0=