#include <bits/stdc++.h>
using namespace std;
long long int pre[200000 + 5], n, d;
long long int Find(long long int x) {
  long long int r = x;
  while (r != pre[r]) r = pre[r];
  long long int i = x, j;
  while (pre[i] != r) {
    j = pre[i];
    pre[i] = r;
    i = j;
  }
  return r;
}
void mix(long long int x, long long int y) {
  long long int fx = Find(x), fy = Find(y);
  if (fx != fy) {
    pre[fy] = fx;
  }
}
void init() {
  for (long long int i = 0; i <= n; i++) pre[i] = i;
}
struct node {
  long long int u, v;
  long long int c;
};
node co[200000 + 5 * 200000 + 5];
long long int a[200000 + 5];
bool cmp(node x, node y) { return x.c < y.c; }
int main() {
  scanf("%lld%lld", &n, &d);
  init();
  for (long long int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  long long int coun = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = i + 1; j <= n; j++) {
      co[coun].u = i;
      co[coun].v = j;
      co[coun++].c = (j - i) * d + a[i] + a[j];
    }
  }
  sort(co, co + coun, cmp);
  long long int ans = 0;
  for (long long int i = 0; i < coun; i++) {
    long long int u = co[i].u, v = co[i].v;
    if (Find(u) != Find(v)) {
      mix(u, v);
      mix(v, u);
      ans += co[i].c;
    }
  }
  printf("%lld", ans);
  return 0;
}
