#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
int a[MAXN], l[MAXN], r[MAXN];
long long l_val[MAXN], r_val[MAXN];
set<pair<long long, int> > st;
void solve() {
  int n, d;
  scanf("%d%d", &n, &d);
  for (int i = (0); i < (int)(n); i++) {
    scanf("%d", &a[i]);
  }
  for (int i = (0); i < (int)(n); i++) {
    l[i] = r[i] = i;
    l_val[i] = r_val[i] = a[i];
  }
  for (int i = (1); i < (int)(n); i++) {
    st.insert(make_pair((long long)l_val[i] + (long long)r_val[i - 1], i - 1));
  }
  long long ans = 0ll;
  while (!st.empty()) {
    ans += st.begin()->first + d;
    int pos = st.begin()->second;
    st.erase(st.begin());
    int _l = l[pos];
    int _r = r[pos + 1];
    r[_l] = _r;
    l[_r] = _l;
    long long l_val_new = min(
        l_val[_l], l_val[pos + 1] + (long long)d * (long long)(pos + 1 - _l));
    long long r_val_new =
        min(r_val[_r], r_val[pos] + (long long)d * (long long)(_r - pos));
    if (l_val_new < l_val[_l] && _l > 0) {
      st.erase(make_pair(r_val[_l - 1] + l_val[_l], _l - 1));
      l_val[_l] = l_val_new;
      st.insert(make_pair(r_val[_l - 1] + l_val[_l], _l - 1));
    }
    if (r_val_new < r_val[_r] && _r < n - 1) {
      st.erase(make_pair(r_val[_r] + l_val[_r + 1], _r));
      r_val[_r] = r_val_new;
      st.insert(make_pair(r_val[_r] + l_val[_r + 1], _r));
    }
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
