#include <bits/stdc++.h>
using namespace std;
const int Nmax = 2e5 + 2;
int n, d, lg;
int a[Nmax], t[2 * Nmax];
struct APM {
  int x, y;
  long long cost;
  bool operator<(const APM &e) const { return cost < e.cost; }
} apm[2 * Nmax];
inline void Union(int x, int y) { t[y] = x; }
int Find(int x) {
  int rad = x, y;
  while (t[rad]) rad = t[rad];
  while (x != rad) {
    y = t[x];
    t[x] = rad;
    x = y;
  }
  return rad;
}
int main() {
  cin >> n >> d;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int minim, pmin;
  minim = a[1];
  pmin = 1;
  for (int i = 2; i <= n; i++) {
    minim += d;
    apm[++lg] = {i, pmin, a[i] + minim};
    if (a[i] <= minim) {
      minim = a[i];
      pmin = i;
    }
  }
  minim = a[n];
  pmin = n;
  for (int i = n - 1; i >= 1; i--) {
    minim += d;
    apm[++lg] = {i, pmin, a[i] + minim};
    if (a[i] <= minim) {
      minim = a[i];
      pmin = i;
    }
  }
  sort(apm + 1, apm + lg + 1);
  long long cost = 0;
  int x, y;
  for (int i = 1; i <= lg; i++) {
    x = Find(apm[i].x);
    y = Find(apm[i].y);
    if (x != y) {
      Union(x, y);
      cost += apm[i].cost;
    }
  }
  cout << cost;
  return 0;
}
