#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = (0); i < ((int)(v.size() - 1)); i++) os << v[i] << " ";
  os << v[v.size() - 1];
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (typename set<T>::iterator it = v.begin(); it != v.end(); it++)
    os << *it << " ";
  return os;
}
const int maxn = 2e5 + 5;
long long N, D;
long long A[maxn];
long long fee(int l, int r) { return (r - l) * D + A[l] + A[r]; }
int main() {
  cin >> N >> D;
  for (int i = (1); i <= (N); i++) {
    cin >> A[i];
  }
  long long ans = 0;
  int l = 1;
  int ll = 1;
  int r = 2;
  while (l < N) {
    while (r < N && A[r] - A[r + 1] > D) {
      r++;
    }
    ans += fee(ll, r);
    for (int i = (l + 1); i < (r); i++) {
      ans += min(fee(ll, i), fee(i, r));
    }
    l = r;
    if ((l - ll) * D + A[ll] > A[l]) {
      ll = r;
    }
    r++;
  }
  cout << ans << endl;
  return 0;
}
