#include<bits/stdc++.h>
using namespace std;
const int MaxN=2e4+5;
const long MaxC=1e14;
long N,C;
long A[MaxN];
long pre[MaxN];
int check(long G){
long sum=0;
for(int n=0;n<N;n++){
if(A[n]<G){
sum+=(G-A[n])*(G-A[n]);
}
}
return sum<=C;
}
int main(){
cin>>N>>C;
for(int i=0;i<N;i++){
cin>>A[i];
}sort(A,A+N);
long R=2e7+5;
long L=0;
long ans=-1;
while(L<=R){
int M=(L+R)/2;
if(check(M)){
ans=M;
L=M+1;
}else{
R=M-1;
}
}
cout<<ans;
}