#include <bits/stdc++.h>
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
template <class Monoid>
class SegmentTree {
 public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;
  SegmentTree(int n, const Func fu, const Monoid &m1) : F(fu), M1(m1) {
    init(n);
  }
  void init(int n) {
    sz = 1;
    while (sz <= n) sz *= 2;
    seg.assign(sz * 2, M1);
  }
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = F(seg[k * 2], seg[k * 2 + 1]);
    }
  }
  Monoid query(int l, int r) {
    Monoid L = M1, R = M1;
    l += sz;
    r += sz;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) L = F(L, seg[l++]);
      if (r & 1) R = F(seg[--r], R);
    }
    return F(L, R);
  }
};
class UnionFind {
 public:
  UnionFind(int n) { parent = vector<int>(n, -1); }
  int root(int a) {
    if (parent[a] < 0) return a;
    return parent[a] = root(parent[a]);
  }
  int size(int a) { return -parent[root(a)]; }
  bool connect(int a, int b) {
    int A = root(a);
    int B = root(b);
    if (A == B) return false;
    if (size(A) > size(B)) swap(A, B);
    parent[B] += parent[A];
    parent[A] = B;
    return true;
  }

 private:
  vector<int> parent;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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];
  using p = pair<long long, long long>;
  auto f = [](p x, p y) { return min(x, y); };
  SegmentTree<p> st(n, f, {1e17, 1e17});
  auto st2 = st;
  auto st3 = st;
  auto st4 = st;
  UnionFind uf(n);
  for (long long i = (long long)(1); i < (long long)(n); i++) {
    st.update(i, {a[i] - i * d, i});
    st2.update(i, {a[i] + i * d, i});
  }
  long long res = 0;
  long long i = 0;
  st3.update(i, {a[0] - 0 * d, 0});
  st4.update(i, {a[0] + 0 * d, 0});
  while (1) {
    auto tp = st.query(0, n), tp2 = st2.query(0, n);
    if (tp.second == 1e17) break;
    long long ri[2] = {tp.second, tp2.second};
    auto tp3 = st3.query(0, tp.second), tp4 = st4.query(tp.second, n);
    long long li[4] = {tp3.second, tp4.second, st3.query(0, tp2.second).second,
                       st4.query(tp2.second, n).second};
    long long tres = 1e17;
    long long id = -1, pid = -1;
    for (long long l = 0; l < (long long)(4); l++)
      for (long long r = 0; r < (long long)(2); r++) {
        if (max(li[l], ri[r]) == 1e17) continue;
        if (chmin(tres, a[li[l]] + a[ri[r]] + d * abs(li[l] - ri[r]))) {
          id = ri[r];
          pid = li[l];
        }
      }
    st.update(id, {1e17, 1e17});
    st2.update(id, {1e17, 1e17});
    st3.update(id, {a[id] - id * d, id});
    st4.update(id, {a[id] + id * d, id});
    uf.connect(i, id);
    res += tres;
    i = id;
  }
  cout << res << endl;
  return 0;
}
