n, temp = map(int, input().split()) a = list(map(int, input().split())) r = max(a) l = 0 while l <= r: m = (l + r) // 2 s = 0 for i in range(n): if a[i] > m: s += (a[i] - m) if s < temp: r = m - 1 else: l = m + 1 print(r)