#include <bits/stdc++.h>
using namespace std;
long long n, d;
int main() {
  cin >> n >> d;
  long long a[n];
  bool use[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  for (long long i = 1; i < n; i++) {
    que.push(pair<long long, long long>(i * d + a[0] + a[i], i));
    use[i] = false;
  }
  use[0] = true;
  long long cost = 0;
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    if (use[p.second]) {
      continue;
    }
    cost += p.first;
    use[p.second] = true;
    for (long long j = 1; j < n; j++) {
      if (!use[j]) {
        que.push(pair<long long, long long>(
            abs(p.second - j) * d + a[p.second] + a[j], j));
      }
    }
  }
  cout << cost;
  return 0;
}
