#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e6+10;
typedef long long LL;
int m,n;
int r,l;
LL h[N];
LL get(LL x){
LL cnt=0;
for(int i=1;i<=n;i++){
if(h[i]>x)cnt+=(h[i]-x);
}
return cnt;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>h[i];
}
sort(h+1,h+1+n);
r=h[n],l=h[1];
while(l<=r){
int mid=(l+r)/2;
if(get(mid)>m){
l=mid+1;
}else if(get(mid)==m){
r=mid-1;
}else{
r=mid-1;
}
}
cout<<l;
return 0;
}