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