#include "fstream"
// #include "queue"
using namespace std;
#ifndef M
#define M 1000000 + 6
#endif
ifstream cin("eko.in");
ofstream cout("eko.out");
long long a[M],n,m;
bool f = 0;
long long cyf()
{
long long i , maX = 0;
cin >> n >> m;
for(i = 1;i <= n;i++)
{
cin >> a[i];
if (a[i] > maX)
{
maX = a[i];
/* code */
}
}
long long l = 0 , r = maX;
long long ans ;
while(l <= r)
{
ans = (l + r)>>1;
long long mm = 0;
for (long long i = 1; i <= n; ++i)
if (a[i] > ans)
mm += a[i]-ans;
if(mm>=m)l=ans+1;
else r=ans-1;
/*
if (mm < m)
r = ans;
else if (mm > m)
l = ans;
else if (mm == m)
{
cout << ans << endl;
f = 1;
break;
}*/
}
cout << r;
cin.close();
cout.close();
return 0;
}
long long CYF=cyf();
int main(long long argc, char const *argv[])
{
/* code */
/*return 0*/;
}