#include <bits/stdc++.h>
using namespace std;
int n, d;
long long f[200020], g[200020], ans, a[200020];
int main() {
  scanf("%d%d", &n, &d);
  for (int i = (1); i <= (n); i++) scanf("%lld", a + i);
  for (int i = (1); i <= (n); i++) f[i] = min(f[i - 1] + d, a[i]);
  for (int i = (n); i >= (1); i--) g[i] = min(g[i + 1] + d, a[i]);
  for (int i = (2); i <= (n - 1); i++) ans += min(f[i], g[i]) + a[i];
  ans += 1ll * d * (n - 1) + a[1] + a[n];
  printf("%lld\n", ans);
}
