#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const long long INF = 100000000;
const long long MOD = 1000000007;
struct UF {
  int par[200000];
  int rank[200000];
  int si[200000];
  void init(int n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      si[i] = 1;
    }
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[x] = y;
      si[y] += si[x];
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
      si[x] += si[y];
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
} uf;
long long n, d;
long long a[200000];
long long l[200000];
long long r[200000];
vector<pair<long long, long long> > edge;
int main() {
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  long long v = MOD * MOD;
  for (int i = 0; i < n; i++) {
    if (v + d > a[i]) {
      v = a[i];
      l[i] = i;
    } else {
      v += d;
      l[i] = l[i - 1];
    }
    if (i != n - 1) {
      edge.push_back(
          pair<long long, long long>(v + d + a[i + 1], (i + 1) * n + l[i]));
    }
  }
  v = MOD * MOD;
  for (int i = n - 1; i >= 0; i--) {
    if (v + d > a[i]) {
      v = a[i];
      r[i] = i;
    } else {
      v += d;
      r[i] = r[i + 1];
    }
    if (i != 0) {
      edge.push_back(
          pair<long long, long long>(v + d + a[i - 1], (i - 1) * n + r[i]));
    }
  }
  sort(edge.begin(), edge.end());
  long long ans = 0;
  uf.init(n);
  for (int i = 0; i < edge.size(); i++) {
    pair<long long, long long> e = edge[i];
    long long from = e.second / n, to = e.second % n;
    if (uf.same(from, to)) continue;
    uf.unite(from, to);
    ans += e.first;
  }
  cout << ans << endl;
}
