#include <stdio.h>
#include <string.h>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long int cutTree(long long int h,long long int N, long long int treeHigh[]);
int main() {
long long int N, H;
scanf("%lld %lld\n", &N, &H);
long long int cutHigh = H, noteHigh = H / 2;
long long int treeHigh[N];
for (int i = 0; i < N; i++) {
scanf("%lld ", &treeHigh[i]);
}
for (; noteHigh > 1; noteHigh /= 2) {
long long int h1 = cutTree(cutHigh, N, treeHigh);
if (h1 > H)
cutHigh += noteHigh;
else {
cutHigh -= noteHigh;
}
}
for (int i = 0; i < 5; i++)
{
if ((cutTree(cutHigh, N, treeHigh) > H)) {
cutHigh++;
} else {
break;
}
}
for (int i = 0; i < 5; i++) {
if ((cutTree(cutHigh, N, treeHigh) < H)) {
cutHigh--;
} else {
break;
}
}
printf("%lld", cutHigh);
return 0;
}
long long int cutTree(long long int h, long long int N, long long int treeHigh[]) {
long long int sum = 0;
for (int i = 0; i < N; i++) {
if (treeHigh[i] > h)
sum += (treeHigh[i] - h);
}
return sum;
}