#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) {
    fread_unlocked(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm)
    while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else
    while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}
int main() {
  int N = getint();
  int D = getint();
  long long kotae = (N - 1) * D;
  int A[200001];
  int C[200001];
  C[0] = 1e9;
  for (int i = 1; i <= (N); i++) {
    A[i] = getint();
    kotae += A[i];
    C[i] = min(C[i - 1] + D, A[i]);
  }
  int mae = 1e9;
  for (int i = N - 1; i > 1; i--) {
    mae = min(mae + D, A[i + 1]);
    kotae += min(A[i], min(mae, C[i - 1]) + D);
  }
  printf("%lld", kotae);
  return 0;
}
