#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  long long root[200001];
  void Init() {
    for (long long i = 0; i < (long long)(200001); ++i) root[i] = -1;
  }
  void unite(long long a, long long b) {
    long long a_root = find(a), b_root = find(b);
    if (a_root != b_root) {
      if (root[a_root] > root[b_root]) {
        root[a_root] += root[b_root];
        root[b_root] = a_root;
      } else {
        root[b_root] += root[a_root];
        root[a_root] = b_root;
      }
    }
  }
  long long find(long long a) {
    if (root[a] < 0)
      return a;
    else {
      root[a] = find(root[a]);
      return root[a];
    }
  }
  long long size(long long a) {
    long long a_root = find(a);
    return root[a_root];
  }
};
long long n, d, a[200000], MIN = LONG_LONG_MAX, I, ans;
vector<pair<long long, pair<long long, long long>>> v;
UnionFind UF;
signed main() {
  UF.Init();
  cin >> n >> d;
  for (long long i = 0; i < (long long)(n); ++i) cin >> a[i];
  for (long long i = 1; i < (long long)(n); ++i) {
    if (MIN > a[i - 1] + d) {
      MIN = a[i - 1] + d;
      I = i - 1;
      v.push_back(make_pair(MIN + a[i], make_pair(I, i)));
    } else
      v.push_back(make_pair(MIN + a[i], make_pair(I, i)));
    MIN += d;
  }
  MIN = LONG_LONG_MAX;
  for (long long i = n - 2; i >= 0; --i) {
    if (MIN > a[i + 1] + d) {
      MIN = a[i + 1] + d;
      I = i + 1;
      v.push_back(make_pair(MIN + a[i], make_pair(I, i)));
    } else
      v.push_back(make_pair(MIN + a[i], make_pair(I, i)));
    MIN += d;
  }
  sort((v).begin(), (v).end());
  for (long long i = 0; i < (long long)(v.size()); ++i) {
    if (UF.find(v[i].second.first) != UF.find(v[i].second.second)) {
      ans += v[i].first;
      UF.unite(v[i].second.first, v[i].second.second);
    }
  }
  cout << ans << endl;
}
