#include<iostream>
#include<algorithm>
using namespace std;
long long N,M;
long long arr[1000005];
int main(){
cin>>N>>M;
for(int i=0;i<N;i++)cin>>arr[i];
sort(arr,arr+N);
long long low=0,high=arr[N-1],mid;
while(low<=high){
mid=low+(high-low)/2;
int mutou=0;
for(int i=0;i<N;i++){
if(arr[i]-mid>0){
mutou+=arr[i]-mid;
}
}
if(mutou>=M){
if(mutou>M)
low=mid+1;
else{
cout<<mid;
return 0;
}
}else{
high=mid-1;
}
}
cout<<mid;
return 0;
}
jvlao帮帮忙,蟹蟹