#include <bits/stdc++.h>
using namespace std;
vector<long long> child;
long long root(vector<long long>& tree, long long i) {
  if (i == tree[i]) {
    for (long long j = (0); j < (child.size()); j++) tree[child[j]] = i;
    child.clear();
    return i;
  } else {
    child.push_back(i);
    return i = root(tree, tree[i]);
  }
}
long long unit(vector<long long>& tree, long long x, long long y) {
  x = root(tree, x);
  y = root(tree, y);
  tree[max(x, y)] = min(x, y);
}
bool isUnit(vector<long long>& tree, long long x, long long y) {
  return root(tree, x) == root(tree, y);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, d;
  cin >> n >> d;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  long long ans = 0, mx = 0;
  vector<long long> miniR(n);
  vector<long long> miniL(n);
  miniL[0] = miniR[n - 1] = 1LL << 60;
  vector<long long> Lind(n), Rind(n);
  for (long long i = (n - 1 - 1); i >= 0; i--) {
    miniR[i] = min(miniR[i + 1] + d, a[i + 1] + d);
    if (miniR[i] == miniR[i + 1] + d)
      Rind[i] = Rind[i + 1];
    else
      Rind[i] = i + 1;
  }
  for (long long i = (1); i < (n); i++) {
    miniL[i] = min(miniL[i - 1] + d, a[i - 1] + d);
    if (miniL[i] == miniL[i - 1] + d)
      Lind[i] = Lind[i - 1];
    else
      Lind[i] = i - 1;
  }
  vector<tuple<long long, long long, long long>> edge(n);
  for (long long i = (0); i < (n); i++) {
    if (miniL[i] + a[i] <= miniR[i] + a[i])
      edge[i] = make_tuple(miniL[i] + a[i], i, Lind[i]);
    if (miniL[i] + a[i] >= miniR[i] + a[i])
      edge[i] = make_tuple(miniR[i] + a[i], i, Rind[i]);
  }
  sort(edge.begin(), edge.end());
  vector<long long> tree(n);
  for (long long i = (0); i < (n); i++) tree[i] = i;
  for (long long i = (0); i < (n); i++) {
    if (isUnit(tree, get<1>(edge[i]), get<2>(edge[i]))) continue;
    unit(tree, get<1>(edge[i]), get<2>(edge[i]));
    ans += get<0>(edge[i]);
  }
  cout << ans << endl;
  return 0;
}
