n, m = map(int,input().split()) a = list(map(int,input().split())) import copy def check(x, a): for i in range(n): if a[i] < m * x: return False elif i < n - 1: a[i + 1] += a[i] - m * x return True ok = 0 ng = 10 ** 9 + 3 while abs(ok - ng) > 1: A = copy.copy(a) mid = (ok + ng) // 2 if check(mid, A): ok = mid else: ng = mid print(ok)