哎呀难过死了
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef unsigned long long ll;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
ll n,m,ans,a[1000006],r;
ll check(ll k){
ll sum=0;
for(int i=1;i<=n;i++)
if(a[i]>k)sum+=a[i]-k;
if(sum>m)return 2;
if(sum<m)return 0;
if(sum==m)return 1;
}
void solve(ll l,ll r){
ll i=l,j=r,mid=(l+r+1)/2;
ll t=check(mid);
if(t==2)
solve(mid+1,j);
else{
if(t==0)
solve(i,mid-1);
else{
ans=mid;
return;
}
}
}
int main(){
n=read();m=read();
for(int i=1;i<=n;i++){
a[i]=read();
r=r>a[i]?r:a[i];
}
solve(0,r);
cout<<ans;
return 0;
}