#include <bits/stdc++.h>
using namespace std;
struct unionf {
  vector<int> data;
  unionf(int size) : data(size, -1) {}
  bool unions(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) {
        int d = x;
        x = y;
        y = d;
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool finds(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int find(int x) { return -data[x]; }
};
long long a[200100];
int lm[200100], rm[200100];
int main() {
  int n;
  long long D;
  cin >> n >> D;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<pair<long long, pair<int, int> > > v;
  int m = 0;
  for (int i = 1; i < n; i++) {
    lm[i] = m;
    v.push_back(
        make_pair(a[i] + a[lm[i]] + D * (i - lm[i]), make_pair(i, lm[i])));
    if (a[i] <= a[m] + D * (i - m)) m = i;
  }
  m = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    rm[i] = m;
    v.push_back(
        make_pair(a[i] + a[rm[i]] + D * (rm[i] - i), make_pair(i, rm[i])));
    if (a[i] <= a[m] + D * (m - i)) m = i;
  }
  sort(v.begin(), v.end());
  unionf uni(n + 10);
  long long out = 0;
  int ed = 0;
  for (int i = 0; i < v.size(); i++) {
    long long c = v[i].first;
    int x = v[i].second.first, y = v[i].second.second;
    if (uni.finds(x, y)) continue;
    out += c;
    uni.unions(x, y);
    ed++;
  }
  assert(ed == n - 1);
  cout << out << endl;
}
