#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, D;
  cin >> N >> D;
  long long a[200001];
  for (long long i = 0; i < N; i++) cin >> a[i];
  long long mincost[200001];
  bool used[200001];
  for (long long i = 0; i < N; i++) {
    mincost[i] = (1LL << 60);
    used[i] = false;
  }
  mincost[0] = 0;
  long long res = 0;
  while (true) {
    long long v = -1;
    for (long long u = 0; u < N; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;
    res += mincost[v];
    for (long long u = 0; u < N; u++) {
      mincost[u] = min(mincost[u], abs(u - v) * D + a[u] + a[v]);
    }
  }
  cout << res << endl;
  return 0;
}
