#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#pragma region 입출력 속도향상
#define FAST_IO() \
{\
ios::sync_with_stdio(false);\
cin.tie(NULL); \
cout.tie(NULL); \
}\
#pragma endregion
vector<long> v;
int main()
{
FAST_IO();
long n, m;
cin >> n >> m;
v.resize(n);
for (int i = 0; i < n; i++)
cin >> v[i];
sort(v.begin(), v.end());
long l = 0, r = v[n - 1];
long res = 0;
while (l <= r)
{
long mid = (l + r) / 2;
long sum = 0;
for (int i = 0; i < n; i++)
{
if (v[i] > mid)
sum += v[i] - mid;
}
if (sum >= m)
{
res = mid;
l = mid + 1;
}
else
r = mid - 1;
}
cout << res;
return 0;
}