#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long d;
  scanf("%d%ld", &n, &d);
  vector<long> a(n);
  for (int i = 0; i < n; i++) scanf("%ld", &a[i]);
  set<pair<long, int>> pairs;
  vector<long> b(n);
  {
    const int j = min_element(a.begin(), a.end()) - a.begin();
    for (int i = 0; i < n; i++) {
      if (i == j) {
        b[i] = 0;
      } else {
        b[i] = abs(i - j) * d + a[i] + a[j];
        pairs.insert(make_pair(b[i], i));
      }
    }
  }
  long cost = 0;
  while (!pairs.empty()) {
    const int j = pairs.begin()->second;
    cost += b[j];
    b[j] = 0;
    pairs.erase(pairs.begin());
    for (int i = j - 1; i >= 0; i--) {
      if (b[i] < (j - i) * d) break;
      pairs.erase(make_pair(b[i], i));
      b[i] = min(b[i], (j - i) * d + a[i] + a[j]);
      pairs.insert(make_pair(b[i], i));
    }
    for (int i = j + 1; i < n; i++) {
      if (b[i] < (i - j) * d) break;
      pairs.erase(make_pair(b[i], i));
      b[i] = min(b[i], (i - j) * d + a[i] + a[j]);
      pairs.insert(make_pair(b[i], i));
    }
  }
  printf("%ld\n", cost);
  return 0;
}
