#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int fh = 1;
  while (!isdigit(c)) {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= fh;
}
long long n, d, a[200010], ansn, f[200010], nv;
struct Info {
  int x, y;
  long long di;
} v[200010 * 2];
bool comp(Info x, Info y) { return x.di < y.di; }
int que(int x) {
  if (f[x] != x) f[x] = que(f[x]);
  return f[x];
}
int main() {
  read(n);
  read(d);
  for (int i = 1; i <= n; i++) read(a[i]);
  int la[200010], nla = 1;
  la[nla] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= nla; j++) {
      v[++nv].x = i;
      v[nv].y = la[j];
    }
    for (int j = 1; j <= nla + 1; j++) {
      if (j == nla + 1) {
        la[++nla] = i;
        break;
      }
      if (a[i] < (i - la[j]) * d + a[la[j]]) {
        for (int k = nla + 1; k >= j + 1; k--) la[k] = la[k - 1];
        la[j] = i;
        break;
      }
    }
    nla = min(nla, 20);
  }
  memset(la, 0, sizeof(la));
  nla = 1;
  la[nla] = n;
  for (int i = n - 1; i >= 1; i--) {
    for (int j = 1; j <= nla; j++) {
      v[++nv].x = i;
      v[nv].y = la[j];
    }
    for (int j = 1; j <= nla + 1; j++) {
      if (j == nla + 1) {
        la[++nla] = i;
        break;
      }
      if (a[i] < (la[j] - i) * d + a[la[j]]) {
        for (int k = nla + 1; k >= j + 1; k--) la[k] = la[k - 1];
        la[j] = i;
        break;
      }
    }
    nla = min(nla, 20);
  }
  for (int i = 1; i <= nv; i++)
    v[i].di = a[v[i].x] + a[v[i].y] + d * (abs(v[i].x - v[i].y));
  sort(v + 1, v + nv + 1, comp);
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= nv; i++) {
    int nx = que(v[i].x), ny = que(v[i].y);
    if (nx != ny) {
      f[nx] = ny;
      ansn += v[i].di;
    }
  }
  cout << ansn << endl;
  return 0;
}
