#include <bits/stdc++.h>
using namespace std;
long long n, d, a[200005];
struct edge {
  long long u, v, cost;
};
bool cmp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }
edge es[400005];
long long V, E;
long long p[200005], r[200005];
void add_edge(long long u, long long v, long long cost) {
  es[E++] = (edge){u, v, cost};
}
void init(long long n) {
  for (long long i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}
long long find(long long x) {
  if (p[x] == x)
    return x;
  else
    return p[x] = find(p[x]);
}
void unite(long long x, long long y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y]) r[x]++;
  }
}
bool same(long long x, long long y) { return find(x) == find(y); }
long long kruskal() {
  sort(es, es + E, cmp);
  init(V);
  long long res = 0;
  for (long long i = 0; i < E; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}
set<pair<long long, long long> > ss;
int main() {
  scanf("%lld%lld", &n, &d);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  ss.clear();
  long long now = d;
  ss.insert(pair<long long, long long>(a[1], 1));
  for (long long i = 2; i <= n; i++) {
    auto it = ss.begin();
    long long to = it->second, cost = it->first;
    add_edge(i, to, cost + now + a[i]);
    ss.insert(pair<long long, long long>(a[i] - now, i));
    now += d;
  }
  ss.clear();
  now = d;
  ss.insert(pair<long long, long long>(a[n], n));
  for (long long i = n - 1; i >= 1; i--) {
    auto it = ss.begin();
    long long to = it->second, cost = it->first;
    add_edge(i, to, cost + now + a[i]);
    ss.insert(pair<long long, long long>(a[i] - now, i));
    now += d;
  }
  V = n;
  printf("%lld\n", kruskal());
  return 0;
}
