#include<bits/stdc++.h>
using namespace std;
long long n,m,maxn = 0;
long long tree[1000100];
int check(long long x)
{
long long mm = 0;
for (int i = 1;i <= n; i ++)
if (tree[i] > x)
mm += tree[i] - x;
return mm;
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++)
{
cin >> tree[i];
maxn = max(maxn, tree[i]);
}
long long l = 1, r = maxn;
while(l < r)
{
long long mid = l + r >> 1;
if (check(mid) < m) r = mid;
else l = mid + 1;
}
cout << l - 1;
return 0;
}