# TLEテスト
N, D = tuple(map(int,input().split()))
A = tuple(map(int, input().split()))

rt = (N-1) * D + A[N-1]
Ll = [N-1]
k = N - 2
for i in range(N - 2, 0, -1):
  t = A[i]  
  if rt > t - (k - i) * D :
    Ll.append(i)
    k = i
    rt = t

rt = (N - 1) * D + A[0]
Lr = [0]
k = 0
for i in range(1, N - 1):
  t = A[i]
  if rt > t + (k - i) * D:
    Lr.append(i)
    k = i
    rt = t

L = []
cnt = -1
for i in range(N-1):
  if i >= Ll[cnt]:
    cnt -= 1
  L.append((0, i, Ll[cnt]))

cnt = -1
for i in range(N-1, 0, -1):
  if i <= Lr[cnt]:
    cnt -= 1
  L.append((0, Lr[cnt], i))

L = tuple(set(L))
L2 = []
for i in range(len(L)):
  a = L[i][1]
  b = L[i][2]
  L2.append((A[a] + A[b] + (b - a) * D , ) + L[i])
  
L2.sort()