#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long d;
  cin >> d;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> r(n);
  r[n - 1] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    if (a[r[i + 1]] + (r[i + 1] - i) * d > a[i]) {
      r[i] = i;
    } else {
      r[i] = r[i + 1];
    }
  }
  int ri = 0;
  int ra = a[0];
  long long ans = 0;
  while (ri != n - 1) {
    ans += ra + a[r[ri + 1]] + (r[ri + 1] - ri) * d;
    for (int i = ri + 1; i < r[ri + 1]; i++) {
      if ((i - ri) * d + ra < (r[ri + 1] - i) * d + a[r[ri + 1]]) {
        ans += a[i] + ra + (i - ri) * d;
      } else {
        ans += a[i] + (r[ri + 1] - i) * d + a[r[ri + 1]];
      }
    }
    ra += (r[ri + 1] - ri) * d;
    if (ra > a[r[ri + 1]]) {
      ra = a[r[ri + 1]];
    }
    ri = r[ri + 1];
  }
  cout << ans << endl;
  return 0;
}
