#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long linf = 1e18;
const long long mod = 1e9 + 7;
long long n, d;
long long a[200000];
long long cost(long long x, long long y) {
  return abs(x - y) * d + a[x] + a[y];
}
signed main() {
  cin >> n >> d;
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  set<long long> cell;
  long long ans = 0LL;
  multimap<long long, long long> corr;
  corr.insert(make_pair(0LL, 0LL));
  while (cell.size() < n) {
    long long len = corr.begin()->first;
    long long c = corr.begin()->second;
    corr.erase(corr.begin());
    if (!cell.insert(c).second) continue;
    ans += len;
    for (long long i = 0; i < n; i++) {
      if (cell.find(i) == cell.end()) {
        corr.insert(make_pair(max(0LL, cost(i, c)), i));
      }
    }
  }
  cout << ans << endl;
  return 0;
}
