#include <bits/stdc++.h>
constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct RMQ {
  using t = long long;
  const static t id = std::numeric_limits<t>::min();
  static t f(const t &a, const t &b) { return std::max(a, b); }
};
struct RmQ {
  using t = long long;
  const static t id = std::numeric_limits<t>::max();
  static t f(const t &a, const t &b) { return std::min(a, b); }
};
template <typename M>
struct SegmentTree {
  int n;
  using T = typename M::t;
  function<T(T, T)> f = M::f;
  T id = M::id;
  std::vector<T> nodes;
  SegmentTree(int _n) {
    _n = minp(_n);
    n = _n;
    nodes.resize(2 * n - 1, id);
  }
  void update(int k, T a) {
    k += n - 1;
    nodes[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      nodes[k] = f(nodes[2 * k + 1], nodes[2 * k + 2]);
    }
  }
  T query(int a, int b) { return query(a, b, 0, 0, n); }
  T get(int k) { return nodes[k + n - 1]; }

 private:
  int minp(int n) {
    int ret = 1;
    while (ret < n) ret *= 2;
    return ret;
  }
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return id;
    if (a <= l && r <= b)
      return nodes[k];
    else {
      T vl = query(a, b, 2 * k + 1, l, (r + l) / 2),
        vr = query(a, b, 2 * k + 2, (r + l) / 2, r);
      return f(vl, vr);
    }
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, d;
  cin >> n >> d;
  vl v(n);
  for (ll i = 0; i < ll(n); ++i) cin >> v[i];
  SegmentTree<RmQ> st(n);
  map<int, int> l, r;
  for (ll i = 0; i < ll(n - 1); ++i) {
    r[i + 1] = i + 2;
  }
  r[-1] = 1;
  for (ll i = 0; i < ll(n - 1); ++i) {
    l[i + 1] = i;
  }
  l[1] = -1;
  vi b(n, 0);
  b[0] = 1;
  {
    ll t = 0;
    for (ll i = 0; i < ll(n - 1); ++i) {
      t += d;
      st.update(i + 1, t + v[i + 1] + v[0]);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < ll(n - 1); ++i) {
    ll val = st.query(0, n);
    ans += val;
    int pos = 0;
    while (pos <= st.n - 1) {
      if (st.nodes[2 * pos + 1] == val) {
        pos = 2 * pos + 1;
      } else {
        pos = 2 * pos + 2;
      }
    }
    pos -= st.n - 1;
    st.update(pos, 1000000001ll * 1000000001ll);
    b[pos] = 1;
    int p = pos;
    while (r[p] < n) {
      ll val = v[pos] + v[r[p]] + abs(pos - r[p]) * d;
      if (st.get(r[p]) <= val) break;
      st.update(r[p], val);
      p = r[p];
    }
    p = pos;
    while (l[p] >= 0) {
      ll val = v[pos] + v[l[p]] + abs(pos - l[p]) * d;
      if (st.get(l[p]) <= val) break;
      st.update(l[p], val);
      p = l[p];
    }
    ll c = r[pos], d = l[pos];
    l[c] = d;
    r[d] = c;
  }
  cout << ans << endl;
}
