#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using piii = pair<ll, pii>;
int n, d, a[200000];
vector<piii> e;
int par[200000], trank[200000];
void init() {
  for (int i = 0; i < n; i++) par[i] = i, trank[i] = 1;
}
int root(int x) {
  if (par[x] == x) return x;
  return (par[x] = root(par[x]));
}
bool unite(int x, int y) {
  x = root(x), y = root(y);
  if (x == y) return false;
  if (trank[x] < trank[y]) swap(x, y);
  par[y] = x;
  trank[x] += trank[y];
  trank[y] = 0;
  return true;
}
int main() {
  scanf("%d %d", &n, &d);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  pii r = pii(a[n - 1] + d, n - 1);
  for (int i = n - 2; 0 <= i; i--) {
    e.emplace_back(r.first + a[i], pii(i, r.second));
    r = min(r, pii(a[i], i));
    r.first += d;
  }
  pii l = pii(a[0] + d, 0);
  for (int i = 1; i < n; i++) {
    e.emplace_back(l.first + a[i], pii(l.second, i));
    l = min(l, pii(a[i], i));
    l.first += d;
  }
  ll cost = 0;
  sort(e.begin(), e.end());
  init();
  for (int i = 0; i < e.size(); i++)
    if (unite(e[i].second.first, e[i].second.second)) cost += e[i].first;
  printf("%lld\n", cost);
}
