#include <bits/stdc++.h>
using namespace std;
const unsigned long long BIGEST = 1000000000000000000 + 1000000000000000000;
const long long BIGER = 1000000000000000000;
const int BIG = 1000000000;
const int MOD = 1000000007;
const long long LMOD = 1000000007;
int n, d;
int a[100005];
int dp[2][100005];
int main() {
  int res = 0;
  scanf("%d%d", &n, &d);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    res += a[i];
  }
  res += d * (n - 1);
  dp[0][1] = a[1];
  for (int i = 2; i <= n; i++) {
    dp[0][i] = min(dp[0][i - 1] + d, a[i]);
  }
  dp[1][n] = a[n];
  for (int i = n - 1; i >= 1; i--) {
    dp[1][i] = min(dp[1][i + 1] + d, a[i]);
  }
  for (int i = 2; i < n; i++) {
    res += min(dp[0][i], dp[1][i]);
  }
  cout << res;
  return 0;
}
