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