N,D=map(int,input().split())
A=list(map(int,input().split()))
B=list(range(N))
A=[(b,a) for b,a in zip(B,A)]

for i in range(N-2,-1,-1):
    for j in range(i,-1,-1):
        if (abs(A[j-1][0]-A[j+1][0])-abs(A[j-1][0]-A[j][0]))*D+A[j+1][1]-A[j][1]<0:
            A[j],A[j+1]=A[j+1],A[j]
ans=0
for i in range(N-1):
    ans += abs(A[i+1][0]-A[i][0])*D+A[i][1]+A[i+1][1]
print(ans)