#include <bits/stdc++.h>
using namespace std;
struct UF {
  long long par[200000];
  UF() {
    for (long long i = 0; i < 200000; i++) par[i] = i;
  }
  long long root(long long x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unit(long long x, long long y) {
    x = root(x);
    y = root(y);
    par[x] = y;
  }
  bool same(long long x, long long y) { return root(x) == root(y); }
};
long long n, d;
long long a[200000];
long long bestR[200000];
long long bestL[200000];
void chmax(long long &a, long long b) { a = max(a, b); }
void chmin(long long &a, long long b) { a = min(a, b); }
long long cal(long long i, long long j) { return abs(i - j) * d + a[i] + a[j]; }
void calcR(long long lx, long long rx, long long ly, long long ry) {
  if (lx >= rx) return;
  long long m = (lx + rx) / 2;
  long long i, it = max(ly, m + 1);
  for (i = it; i < ry; i++) {
    if (cal(m, i) < cal(m, it)) it = i;
  }
  bestR[m] = it;
  calcR(lx, m, ly, it + 1);
  calcR(m + 1, rx, it, ry);
}
void calcL(long long lx, long long rx, long long ly, long long ry) {
  if (lx >= rx) return;
  long long m = (lx + rx) / 2;
  long long i, it = ly;
  for (i = ly; i < min(ry, m); i++) {
    if (cal(m, i) < cal(m, it)) it = i;
  }
  bestL[m] = it;
  calcL(lx, m, ly, ry);
  calcL(m + 1, rx, ly, ry);
}
signed main() {
  long long i;
  cin >> n >> d;
  for (i = 0; i < n; i++) cin >> a[i];
  calcR(0, n - 1, 0, n);
  calcL(1, n, 0, n);
  vector<tuple<long long, long long, long long> > edges;
  for (i = 0; i < n - 1; i++) {
    edges.push_back(
        tuple<long long, long long, long long>(cal(i, bestR[i]), i, bestR[i]));
  }
  for (i = 1; i < n; i++) {
    edges.push_back(
        tuple<long long, long long, long long>(cal(i, bestL[i]), i, bestL[i]));
  }
  sort(edges.begin(), edges.end());
  static UF uf;
  long long sumCost = 0;
  for (i = 0; i < edges.size(); i++) {
    long long cst = get<0>(edges[i]);
    long long u = get<1>(edges[i]);
    long long v = get<2>(edges[i]);
    if (!uf.same(u, v)) {
      uf.unit(u, v);
      sumCost += cst;
    }
  }
  cout << sumCost << endl;
  return 0;
}
