n,m=list(map(int, input().split()))
array=list(map(int, input().split()))

start=0
end=max(array)
result=0
while start<=end:
    total=0
    mid=(start+end)//2

    for x in array:
        if x>mid:
            total+=x-mid

    # if total >=m:
    #     result=mid #조건 만족하니까 저장
    #     start=mid+1
    # else:
    #     end=mid-1

    if total<m:
        end=mid-1
    else:
        result=mid
        start=mid+1
print(result)