N,M = map(int,input().split()) A = list(map(int,input().split())) target = sum(A) // (N * M) # 最大で作れる個数 for i in range(N - 1): if A[i] < target * M: target = A[i] // M A[i + 1] += A[i] - target * M print(target)