#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long D;
  cin >> n >> D;
  int mn_idx = 0;
  long long mn = 1LL << 30;
  long long A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if (A[i] < mn) {
      mn = A[i];
      mn_idx = i;
    }
  }
  int count[n];
  fill(count, count + n, 1);
  count[mn_idx] = n - 1;
  bool f[n];
  fill(f, f + n, false);
  f[mn_idx] = true;
  int k = mn_idx;
  for (int i = k + 1; i < n - 1; i++) {
    if (A[i] < A[k] + D * (i - k)) {
      int c = n - i - 1;
      count[k] -= c;
      count[i] += c;
      k = i;
      f[k] = true;
    }
  }
  k = mn_idx;
  for (int i = k - 1; i > 0; i--) {
    if (A[i] < A[k] + D * (k - i)) {
      count[k] -= i;
      count[i] += i;
      k = i;
      f[k] = true;
    }
  }
  long long ret = 0LL;
  int st = 0;
  while (f[st]) {
    st++;
  }
  int en = 0;
  while (!f[en]) {
    en++;
  }
  for (int i = 0; i < n - 1; i++) {
    ret += abs(en - st) * D + A[st] + A[en];
    count[en]--;
    st++;
    while (f[st]) {
      st++;
    }
    if (count[en] == 0) {
      en++;
      while (!f[en]) {
        en++;
      }
    }
  }
  cout << ret << "\n";
  return 0;
}
