#include <bits/stdc++.h>
typedef struct UnionFind {
  int *parent;
  int n;
} UnionFind;
UnionFind *newUnionFind(int n) {
  UnionFind *u = (UnionFind *)calloc(1, sizeof(UnionFind));
  u->parent = (int *)calloc(n, sizeof(int));
  u->n = n;
  for (int i = 0; i < n; i++) u->parent[i] = -1;
  return u;
}
int root(UnionFind *u, int x) {
  if (u->parent[x] < 0) return x;
  return u->parent[x] = root(u, u->parent[x]);
}
int same(UnionFind *u, int x, int y) { return root(u, x) == root(u, y); }
int getSize(UnionFind *u, int x) { return -u->parent[root(u, x)]; }
void unite(UnionFind *u, int x, int y) {
  x = root(u, x);
  y = root(u, y);
  if (x == y) return;
  if (u->parent[x] > u->parent[y]) {
    int swap = x;
    x = y;
    y = swap;
  }
  u->parent[x] += u->parent[y];
  u->parent[y] = x;
}
typedef struct edge {
  int a, b;
  long long int c;
} edge;
int cmpEdge(const void *a, const void *b) {
  long long int p = ((edge *)a)->c;
  long long int q = ((edge *)b)->c;
  return p == q ? 0 : p < q ? -1 : 1;
}
void run(void) {
  int n, d;
  scanf("%d%d", &n, &d);
  int *a = (int *)calloc(n, sizeof(int));
  int i;
  for (i = 0; i < n; i++) scanf("%d", a + i);
  edge *e = (edge *)calloc(2 * n, sizeof(edge));
  int len = 0;
  long long int cost = a[0] + d;
  int index = 0;
  for (i = 1; i < n; i++) {
    e[len++] = (edge){index, i, cost + a[i]};
    if (cost > a[i]) {
      cost = a[i];
      index = i;
    }
    cost += d;
  }
  cost = a[n - 1] + d;
  index = n - 1;
  for (i = n - 2; i >= 0; i--) {
    e[len++] = (edge){index, i, cost + a[i]};
    if (cost > a[i]) {
      cost = a[i];
      index = i;
    }
    cost += d;
  }
  qsort(e, len, sizeof(edge), cmpEdge);
  long long int ans = 0;
  UnionFind *u = newUnionFind(n);
  for (i = 0; i < len; i++) {
    if (same(u, e[i].a, e[i].b)) continue;
    ans += e[i].c;
    unite(u, e[i].a, e[i].b);
  }
  printf("%lld\n", ans);
}
int main(void) {
  run();
  return 0;
}
