#include <bits/stdc++.h>
using namespace std;
class UnionFindTree {
 private:
  int n;
  vector<int> parent;
  vector<int> rank;

 public:
  int find(int i) {
    if (i == -1)
      return -1;
    else if (parent[i] == i)
      return i;
    else
      return parent[i] = find(parent[i]);
  }
  UnionFindTree(int n) {
    this->n = n;
    parent.resize(n);
    for (int i = 0; i < n; ++i) parent[i] = i;
    rank.assign(n, 0);
  }
  void unite(int a, int b) {
    if ((a = find(a)) != (b = find(b))) {
      if (rank[a] < rank[b]) {
        parent[a] = b;
      } else {
        parent[b] = a;
        if (rank[a] == rank[b]) ++rank[a];
      }
    }
  }
  bool same(int a, int b) { return find(a) == find(b); }
};
const long long INF = LLONG_MAX / 4;
int main() {
  int n;
  long long d;
  cin >> n >> d;
  vector<long long> a(n), b(n);
  vector<int> left(n), right(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
    left[i] = i - 1;
    right[i] = i + 1;
  }
  right[n - 1] = -1;
  multiset<tuple<long long, int, int> > ms;
  for (int i = 0; i < n - 1; ++i)
    ms.insert(make_tuple(a[i] + b[i + 1] + d, i, i + 1));
  UnionFindTree uft(n);
  long long ans = 0;
  while (!ms.empty()) {
    long long cost;
    int i, j;
    tie(cost, i, j) = *ms.begin();
    ms.erase(ms.begin());
    i = uft.find(i);
    j = uft.find(j);
    if (uft.same(i, j)) continue;
    ans += cost;
    a[i] = min(a[i] + d, a[j]);
    b[i] = min(b[i], b[j] + d);
    a[j] = b[j] = -1;
    left[i] = uft.find(left[i]);
    right[i] = uft.find(right[j]);
    left[j] = right[j] = -1;
    uft.unite(i, j);
    if (uft.find(i) != i) {
      swap(i, j);
      swap(a[i], a[j]);
      swap(b[i], b[j]);
      swap(left[i], left[j]);
      swap(right[i], right[j]);
    }
    if (left[i] != -1) ms.insert(make_tuple(a[left[i]] + b[i] + d, left[i], i));
    if (right[i] != -1)
      ms.insert(make_tuple(a[i] + b[right[i]] + d, i, right[i]));
  }
  cout << ans << endl;
  return 0;
}
