import java.io.*;
public class Main {
static int N=1000000+5;
static int n,m;
static int hightest=-1;
static int tree[]=new int[N];
public static boolean check(int mid){
long res=0;
for(int i=0;i<n;i++) {
if(tree[i]>=mid) res+=(tree[i]-mid);
if(res>=m) {
return true;
}
}
return false;
}
public static void main(String args[]) throws IOException{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
String init[]=in.readLine().split(" ");
n=Integer.parseInt(init[0]);
m=Integer.parseInt(init[1]);
String data[]=in.readLine().split(" ");
for(int i=0;i<n;i++) {
tree[i]=Integer.parseInt(data[i]);
hightest=Math.max(tree[i],hightest);
}
int l=0;
int r=hightest;
while(l<r) {
int mid=(l+r+1)/2;
if(check(mid)) l=mid;
else r=mid-1;
}
System.out.println(l);
}
}
第三个测试点出现MLE错误