import sys
n, m = map(int, sys.stdin.readline().rstrip().split())
trees = list(map(int, sys.stdin.readline().rstrip().split()))
longest = max(trees)
for i in range(longest, -1, -1) :
chk=0
for tr in trees :
summ = tr-i
if summ > 0 :
chk+=summ
if chk==m :
print(i); exit()
import sys
n, m = map(int, sys.stdin.readline().rstrip().split())
trees = list(map(int, sys.stdin.readline().rstrip().split()))
trees.sort()
longest = max(trees)
l=0; r = longest-1
while l<=r :
mid=(l+r)//2
res=0
for tr in trees :
if tr-mid> 0 : res+=tr-mid
if res ==m :
print(mid); exit()
elif res > m :
l=mid+1
else :
r = mid-1
=> 항상 m이랑 똑같은 총합을 찾는게 아니라 적어도 m이다!