#include<iostream>
#include<cstdio>
#include<cstring>
int a[10000086],n,m,i;
using namespace std;
unsigned long long l=0,r=0,ans=0,mid=0;
unsigned long long check(unsigned long long x)
{
unsigned long long ss=0;
for(i=0;i<n;i++){
if(a[i]>=x)
ss=ss+(a[i]-x);
}
return ss;
}
int main(){
freopen("eko.in","r",stdin);
freopen("eko.out","w",stdout);
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>a[i];
if(a[i]>r)r=a[i];
}
while(l<=r)
{
mid=(l+r)/2;
if(check(mid)>=m)
{
ans=mid;
l=mid+1;
}else r=mid-1;
}
cout<<ans;
return 0;
}