#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<cstdlib>
using namespace std;
long long a[1000100];
long long n,m,r,mid,t;
int main(){
freopen("eko.in","r",stdin);
freopen("eko.out","w",stdout);
cin>>n>>m;
for(long long i=1;i<=n;i++){
cin>>a[i];
r=max(r,a[i]);
}
long long l=0;
while(l<=r){
mid=(l+r)>>1;
t=0;
for(long long i=1;i<=n;i++)
{
if(a[i]>mid)t+=a[i]-mid;
}
if(t>=m)l=mid+1;
else r=mid-1;
}
cout<<r;
return 0;
}