# -*- coding: utf-8 -*-

import numpy as np
import heapq

def solve():
    N, D = map(int,input().split())
    A = np.array([0]+list(map(int,input().split())))
    V0 = set(range(1,N+1))
    V = {1,}
    C = 0
    E = list()
    i = 1
    for j in V0-V:
        heapq.heappush(E,(abs(j-i)*D + A[i] + A[j], (i,j)))
    heapq.heapify(E)
    while len(V) < N:
        e = heapq.heappop(E)
        if len(set(e[1])&V) == 1:
            i = (set(e[1])-V).pop()
            V |= set(e[1])
            C += e[0]
            for j in V0-V:
                heapq.heappush(E,(abs(j-i)*D + A[i] + A[j], (i,j)))
    res = C
    return str(res)

if __name__ == '__main__':
    print(solve())