#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL N, M;
LL tree[1000010];
bool check(LL x)
{
LL k = 0, sum = 0;
for (int i = 0; i < N; i++)
{
if (tree[i] > x)
sum += tree[i] - x;
}
if (sum >= M) return true;
else return false;
}
LL bs(LL left, LL right)
{
LL mid;
while (left <= right)
{
mid = left + right >> 1;
if (check(mid)) left = mid + 1;
else right = mid - 1;
}
return left;
}
int main()
{
scanf("%lld %lld", &N, &M);
for (int i = 0; i < N; i++) scanf("%lld", &tree[i]);
LL ans = bs(0, 2e9+1);
printf("%lld", ans-1);
return 0;
}