from collections import deque
import sys
#sys.setrecursionlimit(200000)
input = sys.stdin.readline
#n = int(input())
n,d = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
kore = []
class UnionFind():
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]
    def find(self,x):
        while self.table[x] >= 0:
            x = self.table[x]
        return x
 
    def union(self,x,y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] != self.table[s2]:
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                else:
                    self.table[s1] = s2
            else:
                self.table[s1] += -1
                self.table[s2] = s1
        return
kimeta = UnionFind(n)
for i in range(n):
    if i > 0:
        kore.append([a[i] + d+a[i-1],i-1,i])
    if i < n-1:
        kore.append([a[i] + d+a[i+1],i+1,i])
    for j in range(i+2,n):
        if a[i] + (j-i)*d < a[j-1]+d:
            kore.append([a[i] + (j-i)*d+a[j],j,i])
        else:
          break
    for j in range(i-2,-1,-1):
        if a[i] + (i-j)*d < a[j+1]+d:
            kore.append([a[i] + (i-j)*d+a[j],j,i])
        else:
          break
kore.sort()
for i,j,k in kore:
    if kimeta.find(j) != kimeta.find(k):
        kimeta.union(j,k)
        ans += i
print(ans)