https://www.acmicpc.net/problem/2805
n,m=map(int,input().split())
arr=list(map(int,input().split()))
max=max(arr)
min=1
mid=0
while min<=max:
num=0
mid=(min+max)//2
for i in arr:
if i>=mid: num+=i-mid
if num>=m: min=mid+1
else: max=mid-1
print(max)