代码
#include<bits/stdc++.h>
using namespace std;
long long a[1000100],n,m,l=1,r,mid,i;
bool fm(long long x)
{long long s=0;for(i=1;i<=n;i++){if(x<a[i]) s=s+a[i]-x;if(s>=m) return true;}return false;
}
int main()
{cin>>n>>m;for(i=1;i<=n;i++){cin>>a[i];r=max(a[i],r); }while(l<=r){mid=(l+r)/2;if(fm(mid)) l=mid+1;else r=mid-1;}cout<<l-1;return 0;
}