#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[1000005];
bool check(int mid){
long long sum=0;
for(int i=0;i<n;i++){
if(mid<a[i]){
sum+=a[i]-mid;
}
}
return sum>=m;//true往上移
}
int main(){
cin>>n>>m;
int left=0,right=0;
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
right=max(right,a[i]);
}
int mid;
while(left<=right){
mid=(left+right)/2;
if(check(mid))left=mid+1;
else right=mid-1;
}
cout<<right;
return 0;
}