#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
long long n,m,h,ans,mid;long long l,r=-1;
long long tall[1000001];
inline void readln(){
freopen("eko.in","r",stdin);
freopen("eko.out","w",stdout);
cin>>n>>m;
for (long long i=1;i<=n;i++){
cin>>tall[i];
r=max(r,tall[i]);
}
}
inline bool check(int x){
long long ans=0;
for (long long i=1;i<=n;i++){
if (tall[i]>x) ans+=tall[i]-x;
}
if (ans>=m) return 0;
else return 1;
}
inline void work(){
l=1;
while (l<=r){
mid=(l+r)>>1;
long long ans=0;
for (long long i=1;i<=n;i++){
if (tall[i]>mid) ans+=tall[i]-mid;
}
if (ans>=m)
l=mid+1;
else r=mid-1;
}
cout<<r;
}
int main(){
ios::sync_with_stdio(false);
readln();
work();
return 0;
}