from scipy.sparse.csgraph import minimum_spanning_tree
import sys
input = sys.stdin.readline
def solve():
  n,d = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  D = [[0]*n for _ in range(n)]
  for i in range(n):
    for j in range(i+1,n):
      D[i][j] = abs(i-j)*d+a[i]+a[j]
  D = minimum_spanning_tree(D)
  print(int(D.sum()))
solve()