#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int a[N], par[N];
int pr(int v) {
  if (par[v] == v) return v;
  par[v] = pr(par[v]);
  return par[v];
}
inline void join(int u, int v) {
  u = par[u];
  v = par[v];
  par[u] = v;
}
vector<pair<long long, pair<int, int> > > e;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, d;
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    par[i] = i;
  }
  long long mn = a[1] + d;
  int id = 1;
  for (int i = 2; i <= n; i++) {
    e.push_back({mn + a[i], {id, i}});
    if (a[i] < mn) {
      mn = a[i];
      id = i;
    }
    mn += d;
  }
  mn = a[n] + d, id = n;
  for (int i = n - 1; i > 0; i--) {
    e.push_back({mn + a[i], {id, i}});
    if (a[i] < mn) {
      mn = a[i];
      id = i;
    }
    mn += d;
  }
  long long cost = 0;
  sort(e.begin(), e.end());
  for (auto x : e) {
    long long w = x.first;
    int u = x.second.first;
    int v = x.second.second;
    if (pr(u) != pr(v)) join(u, v), cost += w;
  }
  cout << cost;
  return 0;
}
