#include <bits/stdc++.h>
using namespace std;
int n;
int D;
vector<int> v;
vector<pair<long long int, pair<int, int> > > edges;
int fup[1234567];
int fufind(int a) { return (fup[a] == a) ? a : fup[a] = fufind(fup[a]); }
int main() {
  scanf("%d%d", &(n), &(D));
  ;
  for (int i = (0); i < ((n)); ++i) {
    int(a);
    scanf("%d", &(a));
    ;
    (v).push_back(a);
  };
  priority_queue<pair<long long int, int> > kol1;
  kol1.push({-(v[0] - 0 * 1LL * D), 0});
  for (int i = (1); i < (n); ++i) {
    pair<long long int, int> co = kol1.top();
    int j = co.second;
    edges.push_back({abs(i - j) * 1LL * D + v[i] + v[j], {i, j}});
    kol1.push({-v[i] - i * 1LL * D, i});
  }
  priority_queue<pair<long long int, int> > kol2;
  kol2.push({-(v[n - 1] + 0 * 1LL * D), n - 1});
  for (int i = (n - 2); i >= (0); --i) {
    pair<long long int, int> co = kol2.top();
    int j = co.second;
    edges.push_back({abs(i - j) * 1LL * D + v[i] + v[j], {i, j}});
    kol2.push({-v[i] + i * 1LL * D, i});
  }
  sort((edges).begin(), (edges).end());
  long long int ans = 0;
  for (int i = (0); i < (n); ++i) fup[i] = i;
  for (int i = (0); i < (edges.size()); ++i) {
    int a = edges[i].second.first;
    int b = edges[i].second.second;
    a = fufind(a);
    b = fufind(b);
    if (a != b) {
      ans += edges[i].first;
      fup[a] = b;
    }
  }
  printf("%lld\n", ans);
}
