N, M = map(int, input().split()) A = tuple(map(int, input().split())) def isOK(x): cur = 0 for a in A: cur += a - x if cur < 0: return False return True l, r = 0, 10 ** 18 while r - l > 1: m = (r + l) // 2 if isOK(m * M): l = m else: r = m print(l)