from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if self.table[s1] > self.table[s2]:
			self.table[s2] = s1
			self.table[s1] -= 1
		else:
			self.table[s1] = s2
			self.table[s2] -= 1
		return

n, d = map(int, input().split())
a = list(map(int, input().split()))
uf = UnionFind(n)
cost_left_num = [x for x in a]
cost_left_id = [i for i in range(n)]
cost_right_num = [x for x in a]
cost_right_id = [i for i in range(n)]
limit_left = [i for i in range(n)]
limit_right = [i for i in range(n)]
q = []
for i in range(n-1):
	heappush(q, (a[i] + a[i+1])*(10**12) + i * (10**6) + i+1)

cnt = n
ans = 0
while cnt > 1:
	l = heappop(q)
	c = l // (10**12)
	i = (l - c * (10**12)) // (10**6)
	j = l % 10**6
	if uf.same(i, j):
		continue
	else:
		cnt -= 1
		x, y = uf.find(i), uf.find(j)
		#print(c, x, y)
		uf.unite(x, y)
		z = uf.find(x)
		ans += d + c
		limit_right[z] = limit_right[y]
		limit_left[z] = limit_left[x]

		if a[cost_left_id[x]] + d * (cost_left_id[x] - limit_left[z]) <= a[cost_left_id[y]] + d * (cost_left_id[y] - limit_left[z]):
			cost_left_num[z] = cost_left_num[x]
			cost_left_id[z] = cost_left_id[x]
		else:
			cost_left_num[z] = a[cost_left_id[y]] + d * (cost_left_id[y] - limit_left[z])
			cost_left_id[z] = cost_left_id[y]

		if a[cost_right_id[y]] + d * (limit_right[z] - cost_right_id[y]) <= a[cost_right_id[x]] + d * (limit_right[z] - cost_right_id[x]):
			cost_right_num[z] = cost_right_num[y]
			cost_right_id[z] = cost_right_id[y]
		else:
			cost_right_num[z] = a[cost_right_id[x]] + d * (limit_right[z] - cost_right_id[x])
			cost_right_id[z] = cost_right_id[x]

		if limit_left[z] > 0:
			w = uf.find(limit_left[z]-1)
			heappush(q, (cost_left_num[z] + cost_right_num[w]) * (10**12) + w * (10**6) + z)

		if limit_right[z] < n-1:
			w = uf.find(limit_right[z]+1)
			heappush(q, (cost_left_num[w] + cost_right_num[z]) * (10**12) + z * (10**6) + w)
		
		#print(*limit_left)
		#print(*limit_right)
		#print("-----")

print(ans)