#include <bits/stdc++.h>
using namespace std;
inline bool ZXBs_fast_input(int& x) {
  x = 0;
  int c;
  int sign = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') sign = -1;
  x = c ^ '0';
  while ((c = getchar()) >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0');
  x *= sign;
  return 1;
}
inline bool ZXBs_fast_output(int x) {
  if (x >= 10) ZXBs_fast_output(x / 10);
  putchar(x % 10 + '0');
  return 1;
}
const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;
int n, d;
int a[200200];
int dpL[200200];
int dpR[200200];
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> d;
  for (int i = 0; i < n; i++) cin >> a[i];
  int res = d * (n - 1);
  for (int i = 0; i < n; i++) res += a[i];
  dpL[0] = a[0];
  for (int i = 1; i < n; i++) {
    dpL[i] = min(a[i], dpL[i - 1] + d);
  }
  dpR[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    dpR[i] = min(a[i], dpR[i + 1] + d);
  }
  for (int i = 1; i < n - 1; i++) {
    res += min(dpL[i], dpR[i]);
  }
  cout << res << endl;
  return 0;
}
