#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int maxn = 2e5 + 10;
const int maxm = 200005;
int Read() {
  int x = 0, t = 1;
  char c = getchar();
  if (c == '-') {
    t = -1;
    c = getchar();
  }
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return t * x;
}
long long a[maxn], n, d;
long long dpl[maxn], dpr[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  n = Read(), d = Read();
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = Read();
    ans += a[i];
  }
  ans += (n - 1) * d;
  dpl[1] = a[1];
  dpr[n] = a[n];
  for (int i = 2; i <= n; i++) {
    dpl[i] = min(a[i], dpl[i - 1] + d);
  }
  for (int i = n - 1; i >= 1; i--) {
    dpr[i] = min(a[i], dpr[i + 1] + d);
  }
  for (int i = 2; i < n; i++) {
    ans += min(dpl[i], dpr[i]);
  }
  cout << ans << endl;
  return 0;
}
