import bisect

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

total = 0
# M = [ (A[i] - (i + 1) * D, i) for i in range(len(A))]
C = []
for i in range(N):
    cost = A[i] - (i + 1) * D
    index = bisect.bisect_left(C, cost)
    C.insert(index, cost)
    if i != 0:
        # if index == 0:
        #     index = 1
        # else:
        index = index - 1
        total += C[index] + A[i] + (i + 1) * D

print(total)
