#include <bits/stdc++.h>
using namespace std;
int getint() {
  char ch;
  while (!isdigit(ch = getchar()))
    ;
  int x = ch - 48;
  while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
  return x;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, D;
  cin >> N >> D;
  long long kotae = (N - 1) * D;
  int A[200001];
  long long C[200001];
  C[0] = 1e18;
  for (int i = 1; i <= (N); i++) {
    A[i] = getint();
    kotae += A[i];
    C[i] = min(C[i - 1] + D, (long long)A[i]);
  }
  long long mae = 1e18;
  for (int i = N - 1; i > 1; i--) {
    mae = min(mae + D, (long long)A[i + 1]);
    long long kari = min(mae, C[i - 1]) + D;
    kotae += min((long long)A[i], kari);
  }
  cout << (kotae) << "\n";
  return 0;
}
