#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int n;
ll D;
ll a[200005];
vector<vector<ll> > edges;
void solve(int L, int R) {
  if (R - L <= 1) return;
  int mid = (R + L) / 2;
  ll lval = INF;
  int lidx = -1;
  for (int i = L; i < mid; i++) {
    ll tmp = a[i] - D * i;
    if (lval > tmp) {
      lidx = i;
      lval = tmp;
    }
  }
  ll rval = INF;
  int ridx = -1;
  for (int i = mid; i < R; i++) {
    ll tmp = a[i] + D * i;
    if (rval > tmp) {
      ridx = i;
      rval = tmp;
    }
  }
  for (int i = L; i < mid; i++) {
    edges.push_back({a[i] + a[ridx] + D * (ridx - i), i, ridx});
  }
  for (int i = mid; i < R; i++) {
    edges.push_back({a[i] + a[lidx] + D * (i - lidx), lidx, i});
  }
  solve(L, mid);
  solve(mid, R);
}
struct UnionFind {
  vector<int> data;
  UnionFind(int sz) : data(sz, -1) {}
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    bool is_union = (x != y);
    if (is_union) {
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return is_union;
  }
  int find(int x) {
    if (data[x] < 0) {
      return x;
    } else {
      data[x] = find(data[x]);
      return data[x];
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -data[find(x)]; }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> D;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(0, n);
  sort(edges.begin(), edges.end());
  UnionFind uf(n);
  ll ans = 0;
  for (vector<ll>& e : edges) {
    ll cost = e[0];
    int u = e[1], v = e[2];
    if (!uf.same(u, v)) {
      uf.unite(u, v);
      ans += cost;
    }
  }
  cout << ans << endl;
  return 0;
}
