#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
int u[maxn];
long long best[maxn], who[maxn];
vector<int> guys[maxn];
void init(){
  for(int i = 0; i < maxn; i++) u[i] = i;
}
int find(int x){
  if(x == u[x]) return x;
  return u[x] = find(u[x]);
}
int main(){
  int n; long long d; cin >> n >> d;
  vector<int> a(n); for(int & i : a) cin >> i;
  init();
  int comp = n;
  long long ans = 0;
  while(comp != 1){
    for(int i = 0; i < n; i++) guys[i].clear(), best[i] = 1ll<<62, who[i] = -1;
	multiset<pair<long long, int> > smallest;
    for(int i = 0; i < n; i++) {
      int id = find(i);
//      for(int v : guys[id]) smallest.erase(smallest.find(make_pair(-d * v + a[v], v)));
      if(!smallest.empty()){
      	pair<long long, int> myBest = *smallest.begin();
        long long realCost = d * i + a[i] + myBest.first;
        if(best[id] > realCost){
          best[id] = realCost;
          who[id] = myBest.second;
        }
      }
//      guys[id].push_back(i);
//      for(int v : guys[id]) smallest.insert(make_pair(-d * v + a[v], v));
      smallest.insert(make_pair(-d * i + a[i], v));
    }
    smallest.clear();
    for(int i = 0; i < n; i++) guys[i].clear();
    for(int i = n-1; i >= 0; i--) {
      int id = find(i);
      //for(int v : guys[id]) smallest.erase(smallest.find(make_pair(d * v + a[v], v)));
      if(!smallest.empty()){
      	pair<long long, int> myBest = *smallest.begin();
        long long realCost = - d * i + a[i] + myBest.first;
        if(best[id] > realCost){
          best[id] = realCost;
          who[id] = myBest.second;
        }
      }
      //guys[id].push_back(i);
      //for(int v : guys[id]) smallest.insert(make_pair(d * v + a[v], v));
      smallest.insert(make_pair(d * i + a[i], v));
    }
    for(int i = 0; i < n; i++) if(who[i] != -1){
      int id = find(i), idWho = find(who[i]);
      if(id != idWho){
        ans += best[id];
        u[id] = idWho;
        comp--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
