#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
template <typename T>
void chk_min(T &a, T b) {
  if (a > b) a = b;
}
long long a[MAXN];
int main(void) {
  int n;
  long long d;
  scanf("%d%lld", &n, &d);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) ans += a[i];
  for (int i = 1; i <= n; ++i) chk_min(a[i], a[i - 1] + d);
  for (int i = n - 1; i >= 1; --i) chk_min(a[i], a[i + 1] + d);
  for (int i = 1; i <= n; ++i) ans += a[i];
  printf("%lld", ans + d * (n - 1) - a[1] - a[n]);
  return 0;
}
