#include <bits/stdc++.h>
using namespace std;
long long n, m, val[200100], res;
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld", &val[i]);
  res += accumulate(val + 1, val + n + 1, 0);
  for (long long i = 2; i <= n; i++) val[i] = min(val[i], val[i - 1] + m);
  for (long long i = n - 1; i; i--) val[i] = min(val[i], val[i + 1] + m);
  printf("%lld\n", res + accumulate(val + 1, val + n + 1, 0) - val[1] - val[n] +
                       (n - 1) * m);
  return 0;
}
