#include <bits/stdc++.h>
int nextInt();
long long int min(long long int a, long long int b) { return a > b ? b : a; }
long long int dif(int a, int b) { return a < b ? b - a : a - b; }
int N, D, A[200000], v, u, i;
long long int mincost[200000], ans;
char used[200000];
long long int cost(int v, int u) { return dif(v, u) * D + A[v] + A[u]; }
int main() {
  N = nextInt();
  D = nextInt();
  for (i = 0; i < N; i++) {
    A[i] = nextInt();
    mincost[i] = 9223372036854775807;
    used[i] = 0;
  }
  mincost[0] = 0;
  while (1) {
    v = -1;
    for (u = 0; u < N; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) {
        v = u;
      }
    }
    if (v == -1) {
      break;
    }
    used[v] = 1;
    ans += mincost[v];
    for (u = 0; u < N; u++) {
      mincost[u] = min(mincost[u], cost(u, v));
    }
  }
  printf("%lld\n", ans);
  return 0;
}
int nextInt() {
  int f = 0;
  char c = getchar();
  while ((c < '0') || ('9' < c)) {
    c = getchar();
  }
  while ((c >= '0') && (c <= '9')) {
    f = f * 10 + (c - '0');
    c = getchar();
  }
  return f;
}
