def check(m): cnt = 0 for i in range(N): if m * M > A[i] + cnt: return False cnt += A[i] - m * M if cnt < 0: return False return True N, M = map(int, input().split()) A = list(map(int, input().split())) yes = 0 no = 10 ** 18 while no - yes != 1: mid = (yes + no)//2 if check(mid): yes = mid else: no = mid print(yes)