#include <bits/stdc++.h>
#define N 1000000
#define ll long long
using namespace std;
ll a[N+3];
int n,ans;
ll S;

bool check(int k)
{
    ll sum=0;
    for (int i=1;i<=n;i++)
        sum+=max(0LL,a[i]-k);
    return (S<=sum);
}
int main()
{
    freopen("mining.inp","r",stdin);
    freopen("mining.out","w",stdout);
    cin>>n>>S;
    for (int i=1;i<=n;i++) cin>>a[i];
    int l=0,r=*max_element(a+1,a+n+1);
    while (l<=r)
    {
        int mid=(l+r)/2;
        if (check(mid))
        {
            ans=mid;
            l=mid+1;
        }
        else r=mid-1;
    }
    cout<<ans;
    return 0;
}
