#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int maxn = 2e5 + 5;
int n, d;
int a[maxn];
long long ans;
int main() {
  scanf("%d%d", &n, &d);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", a + i);
    ans += a[i];
  }
  for (int i = (1); i < (n); ++i) a[i] = min(a[i], a[i - 1] + d);
  for (int i = n - 2; i >= 0; --i) a[i] = min(a[i], a[i + 1] + d);
  for (int i = (1); i < (n - 1); ++i) ans += a[i];
  ans += d * (n - 1);
  printf("%lld\n", ans);
  return 0;
}
