#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long i, j, k, n, d, ans = 0, min = 1e18, minn;
  scanf("%lld%lld", &n, &d);
  long long a[n], b[n];
  for (i = 0; i < n; ++i) scanf("%lld", &a[i]), b[i] = a[i];
  for (i = 0; i < n; ++i) {
    b[i] += d * i;
  }
  set<pair<long long, long long> > s;
  for (i = 1; i < n; ++i) {
    s.insert(make_pair(b[i], i));
  }
  for (i = 0; i < n - 1; ++i) {
    ans += (*s.begin()).first - d * i + a[i];
    s.erase(s.find(make_pair(b[i + 1], i + 1)));
  }
  printf("%lld", ans);
  return 0;
}
