from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix

n, d = map(int, input().split())
a = [0] + list(map(int, input().split()))

row = []
col = []
cost = []
for i, e in enumerate(a[1:], 1):
    if i == 1:
        mn = a[i] - i * d
        mn_i = i

    else:
        row.append(i)
        col.append(mn_i)
        cost.append(a[i] + i * d + mn)

        if a[i] - i * d < mn:
            mn = a[i] - i * d
            mn_i = i

for i, e in enumerate(a[1:][::-1]):
    ri = n - i
    if ri == n:
        mn = a[ri] + ri * d
        mn_i = ri

    else:
        row.append(ri)
        col.append(mn_i)
        cost.append(a[ri] - ri * d + mn)

        if a[ri] + ri * d < mn:
            mn = a[ri] + ri * d
            mn_i = ri

g = csr_matrix((cost, (row, col)), shape=(n + 1, n + 1))
mst = minimum_spanning_tree(g).astype(int)
ans = mst.sum()
print(ans)
