#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int infi = 2147483600;
const long long infl = 1e17;
struct SegmentTree {
 private:
  int N;
  vector<long long> node;
  long long e;

 public:
  SegmentTree() {}
  SegmentTree(long long e) : e(e) {}
  void __init__(int sz) {
    N = 1;
    while (N < sz) N *= 2;
    node.resize(2 * N - 1, e);
  }
  void build(vector<long long> &v) {
    int sz = (int)(v.size());
    __init__(sz);
    for (long long i = 0; i < (long long)sz; i++) {
      node[i + N - 1] = v[i];
    }
    for (int i = N - 2; i >= 0; i--) {
      node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  void update(int k, long long x) {
    k += N - 1;
    node[k] = x;
    while (k > 0) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
    return;
  }
  long long query(int a, int b) { return query(a, b, 0, 0, N); }
  long long query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return e;
    if (a <= l && r <= b) return node[k];
    long long vl, vr;
    vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
  long long show_one(int i) {
    if (0 <= i && i < N) return node[i + N - 1];
    return e;
  }
  int need() {
    int k = 0;
    while (k < N - 1) {
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
      if (node[k] == node[2 * k + 1]) {
        k = 2 * k + 1;
      }
      if (node[k] == node[2 * k + 2]) {
        k = 2 * k + 2;
      }
    }
    return k - N + 1;
  }
  void view() {
    for (long long k = (long long)N - 1; k < (long long)2 * N - 1; k++) {
      if (node[k] == e)
        cout << "inf ";
      else
        cout << node[k] << " ";
    }
    cout << endl;
    return;
  }
};
struct UnionFind {
  vector<int> root;
  int n;
  void __init__(int sz) {
    n = sz;
    root.resize(n, -1);
  }
  int find(int x) {
    if (root[x] >= 0) {
      root[x] = find(root[x]);
      return root[x];
    }
    return x;
  }
  void unit(int a, int b) {
    int ra, rb;
    ra = find(a);
    rb = find(b);
    if (ra == rb) {
      return;
    } else if (root[ra] <= root[rb]) {
      root[ra] += root[rb];
      root[rb] = ra;
    } else {
      root[rb] += root[ra];
      root[ra] = rb;
    }
    return;
  }
  int count() {
    set<int> cnt;
    for (long long i = 0; i < (long long)n; i++) cnt.insert(find(i));
    return cnt.size();
  }
};
int main() {
  long long n, d;
  cin >> n >> d;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)n; i++) cin >> a[i];
  SegmentTree seg(infl);
  seg.build(a);
  long long ans = 0;
  long long cnt = n - 1;
  vector<vector<long long> > idx(n, vector<long long>(2));
  for (long long i = 0; i < (long long)n; i++) {
    idx[i][0] = i;
    idx[i][1] = i;
  }
  while (cnt > 0) {
    int k = seg.need();
    long long x = seg.show_one(k);
    if (k > 0 && seg.show_one(k - 1) < infl) {
      ans += seg.show_one(k - 1) + x + d;
      seg.update(idx[k - 1][0],
                 min(x + (k - idx[k - 1][0]) * d, seg.show_one(idx[k - 1][0])));
      if (idx[k - 1][0] < k - 1) {
        seg.update(k - 1, infl);
      }
      idx[idx[k][1]][0] = idx[k - 1][0];
      idx[k][0] = idx[k - 1][0];
      idx[k - 1][1] = idx[k][1];
      idx[idx[k - 1][0]][1] = idx[k][1];
      cnt--;
    }
    if (k < n && seg.show_one(k + 1) < infl) {
      ans += seg.show_one(k + 1) + x + d;
      seg.update(idx[k + 1][1],
                 min(x + (idx[k + 1][1] - k) * d, seg.show_one(idx[k + 1][1])));
      if (idx[k + 1][1] > k + 1) {
        seg.update(k + 1, infl);
      }
      idx[idx[k][0]][1] = idx[k + 1][1];
      idx[k][1] = idx[k + 1][1];
      idx[idx[k + 1][1]][0] = idx[k][0];
      idx[k + 1][0] = idx[k][0];
      cnt--;
    }
    seg.update(k, infl);
  }
  cout << ans << endl;
}
