#include <iostream>
#include <cstdio>
using namespace std;
int A[1000001];
typedef unsigned long long LL;
int main(){
freopen("eko.in","r",stdin);
freopen("eko.out","w",stdout);
int n;
cin>>n;
unsigned long long m,ansl=0;
int r;
cin>>m;
for(int i=1;i<=n;i++){
cin>>A[i];
ansl+=A[i];
r=max(r,A[i]);
}
int l=0;r++;
unsigned long long ansr=0;
while(l+1<r){
int mid=(l+r)>>1;
LL ansm=0;
for(int i=1;i<=n;i++)
if(A[i]>mid)
ansm+=A[i]-mid;
if(ansm<=m&&m<=ansl){
r=mid;
ansr=ansm;
}
if(ansm>=m&&m>=ansr){
l=mid;
ansl=ansm;
}
}
if(ansr>=m)
cout<<r<<endl;
else cout<<l<<endl;
return 0;
}