//In the name of God

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int N = 2e5+10 , mod = 1e9+7;

int a[N] , par[N];

int pr(int v){
   if(par[v] == v)
      return v;
   par[v] = pr(par[v]);
   return par[v];
}

inline void join(int u , int v){
   u = par[u];
   v = par[v];
   par[u] = v;
}

vector < pair <ll , pii> > e;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , d;
   cin >> n >> d;
   if(n > N / 2)
      cout << a[10000000000000000000000];
   for(int i = 1 ; i <= n ; i++){
      cin >> a[i];
      par[i] = i;
   }
   ll mn = a[1] + d;
   int id = 1;
   for(int i = 2 ; i <= n ; i++){
      e.push_back({mn + a[i] , {id , i}});
      if(a[i] < mn){
         mn = a[i];
         id = i;
      }
      mn += d;
   }
   mn = a[n] + d , id = n;
   for(int i = n - 1 ; i > 0 ; i--){
      e.push_back({mn + a[i] , {id , i}});
      if(a[i] < mn){
         mn = a[i];
         id = i;
      }
      mn += d;
   }
   ll cost = 0;
   sort(e.begin() , e.end());
   for(auto x : e){
      ll w = x.first;
      int u = x.second.first;
      int v = x.second.second;
      if(pr(u) != pr(v))
         join(u , v) , cost += w;
   }
   cout << cost;
   return 0;
}
