#include<iostream>
#include<algorithm>
using namespace std;
int m,n,tree[1000005];
long long h,ans = 0;
int main(){
cin>>m>>n;
int right = 1000000000;
int left = 0;
for(int i = 1;i <= m;i++){
cin>>tree[i];
}
sort(tree + 1,tree + m + 1);
while(left < right){
ans = 0;
h = (left+ right) / 2;
for(int i = 1;i <= m;i++){
if(tree[i] > h){
ans += tree[i] - h;
}
}
if(ans < n){
right = h;
}
if(ans > n){
left = h + 1;
}
if(ans == n){
cout<<h<<endl;
return 0;
}
}
cout<<left - 1<<endl;
return 0;
}