#include <bits/stdc++.h>
using namespace std;
struct UF {
  int n;
  vector<int> parent, rank;
  UF(int n_ = 0) : n(n_), parent(n_), rank(n_, 0) {
    for (int i = 0; i < n_; i++) parent[i] = i;
  }
  int find(int a) { return parent[a] != a ? parent[a] = find(parent[a]) : a; }
  bool same(int a, int b) { return find(a) == find(b); }
  bool unite(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return false;
    if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      parent[b] = a;
      if (rank[a] == rank[b]) rank[a]++;
    }
    return true;
  }
};
int n;
long d, a[2 << 17];
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  priority_queue<pair<long, pair<int, int> > > P;
  for (int i = 0; i < n - 1; i++) {
    P.push(make_pair(-d - a[i] - a[i + 1], make_pair(i, i + 1)));
  }
  UF uf(n);
  long ans = 0;
  while (!P.empty()) {
    long cost = -P.top().first;
    int x = P.top().second.first, y = P.top().second.second;
    P.pop();
    if (uf.unite(x, y)) {
      ans += cost;
      if (x > 0)
        P.push(
            make_pair(-d * (y - x + 1) - a[y] - a[x - 1], make_pair(x - 1, y)));
      if (y < n - 1)
        P.push(
            make_pair(-d * (y - x + 1) - a[y + 1] - a[x], make_pair(x, y + 1)));
    }
  }
  cout << ans << endl;
}
