#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long h[1000050];
long long sear(long long l,long long r){
long long mid = (r + l) / 2;
long long sum = 0;
for(int i = 1; i <= n; ++i){
if(h[i] > mid)sum += h[i] - mid;
}
if(sum == m || r - l == 1)return mid;
if(sum > m)return sear(mid,r);
if(sum < m)return sear(l,mid);
}
int main(){
scanf("%lld%lld",&n,&m);
long long max = 0;
for(int i = 1; i <= n; ++i){
cin >> h[i];
if(h[i] > max)max = h[i];
}
cout << sear(1,max);
return 0;
}