#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << ", " << p.second << ")";
  return o;
}
int main(void) {
  int n;
  long long D;
  cin >> n >> D;
  vector<long long> a(n);
  for (int i = 0; i < int(n); ++i) cin >> a[i];
  long long res = accumulate((a).begin(), (a).end(), 0LL) -
                  *min_element((a).begin(), (a).end());
  vector<long long> lmin(n);
  vector<long long> rmin(n);
  lmin[0] = 1e18;
  long long mn = a[0];
  for (int i = 1; i <= int(n - 1); ++i) {
    mn += D;
    lmin[i] = mn;
    if (mn > a[i]) mn = a[i];
  }
  mn = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    mn += D;
    rmin[i] = mn;
    if (mn > a[i]) mn = a[i];
  }
  for (int i = 0; i < int(n); ++i) {
    res += min(lmin[i], rmin[i]);
  }
  cout << res << endl;
  return 0;
}
