import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))

OK=0
NG=max(A)+1

while NG>OK+1:
    mid=(OK+NG)//2

    now=0
    for a in A:
        now+=a
        now-=mid*M

        if now<0:
            NG=mid
            break
    else:
        if now<0:
            NG=mid
        else:
            OK=mid

print(OK)