rt.
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define yes "Yes"
#define no "No"
#define debug(x) cout<<#x<<" = "<<x<<"\n"
#define rep(i,x,y) for(int i=x;i<=(y);++i)
#define per(i,x,y) for(int i=x;i>=(y);--i)
typedef long long ll;
typedef unsigned long long ull;
namespace fast{
inline int sf(){
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
return x*f;
}
inline void out(int n){
if(n<0){putchar('-');n=-n;}
if(n>9)out(n/10);
putchar(n%10^48);
}
}
using namespace std;
using namespace fast;
const int INF=0x3f3f3f3f;
const ll LNF=0x3f3f3f3f3f3f3f3f;
const int N=1e6+10;
int n,k;
int a[N];
bool check(ll x){
ll sum=0;
rep(i,1,n){
sum+=min(0ll,(a[i]-1)-x);
}
return abs(sum)<=x*k;
}
void solve(){
cin>>n>>k;
rep(i,1,n) cin>>a[i];
ll l=0,r=1e12,ans=0;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid)){
ans=mid;
l=mid+1;
}else{
r=mid-1;
}
}
cout<<ans;
}
int main(){
int t=1;
while(t--){
solve();
}
return 0;
}