#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const long long INF = 100000000;
const long long MOD = 1000000007;
struct UF {
  int par[(1 << 18)];
  int rank[(1 << 18)];
  int si[(1 << 18)];
  void init(int n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      si[i] = 1;
    }
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[x] = y;
      si[y] += si[x];
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
      si[x] += si[y];
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
} uf;
struct segtree {
  int n;
  pair<long long, long long> dat[2 * (1 << 18) - 1];
  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++)
      dat[i] = pair<long long, long long>(INF, 0);
    for (int i = n - 1; i < 2 * n - 1; i++) dat[i].second = i - (n - 1);
  }
  void update(int k, long long a) {
    k += n - 1;
    dat[k].first = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  pair<long long, long long> query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return pair<long long, long long>(INF, 0);
    if (a <= l && r <= b)
      return dat[k];
    else {
      pair<long long, long long> vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      pair<long long, long long> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr);
    }
  }
} seg;
long long n, d;
long long a[200000];
bool saw[200000];
vector<pair<long long, long long> > edge;
int main() {
  cin >> n >> d;
  uf.init(n);
  seg.init(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) seg.update(i, a[i]);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    pair<long long, long long> p = seg.query(0, seg.n, 0, 0, seg.n);
    if (p.second != 0 && !saw[p.second - 1]) {
      ans += seg.dat[seg.n - 1 + p.second].first +
             seg.dat[seg.n - 1 + p.second - 1].first + d;
      seg.update(p.second - 1, min(seg.dat[seg.n - 1 + p.second].first + d,
                                   seg.dat[seg.n - 1 + p.second - 1].first));
    }
    if (p.second != n - 1 && !saw[p.second + 1]) {
      ans += seg.dat[seg.n - 1 + p.second].first +
             seg.dat[seg.n - 1 + p.second + 1].first + d;
      seg.update(p.second + 1, min(seg.dat[seg.n - 1 + p.second].first + d,
                                   seg.dat[seg.n - 1 + p.second + 1].first));
    }
    seg.update(p.second, INF);
    saw[p.second] = true;
  }
  cout << ans << endl;
}
