#include <iostream>
#include <cstring>
#include <algorithm>
typedef long long LL;
using namespace std;
LL n,a[1000010],m, s;
LL mid(LL m)
{
LL midd=m,res=0;
for (int i = 0; i < n; i++)
{
if (a[i] > m)
{
res += a[i] - m;
}
}
return res;
}
int main()
{
LL l, r;
scanf("%lld%lld", &n, &s);
for (LL i = 0; i < n; i++)
{
scanf("%lld", &a[i]);
}
sort(a, a + n);
l = a[0];
r = a[n-2];
while (l <= r)
{
if (mid((l+r)/2) > s)
{
l = (l + r) / 2 + 1;
}
if (mid((l+r)/2) == s)
{
l = (l + r) / 2 ;
break;
}
else
{
r = (l + r) / 2 - 1;
}
}
printf("%lld",l);
return 0;
}