#include <bits/stdc++.h>
using namespace std;
const int SZ = 200005;
const long long INF = 1000000000000005LL;
long long dis[SZ];
long long arr[SZ];
int nq[SZ];
priority_queue<pair<long long, int> > pq;
int n;
long long d;
long long myf(int i, int j) {
  return d * (long long)abs(i - j) + arr[i] + arr[j];
}
int main(void) {
  scanf("%d %lld", &n, &d);
  for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  for (int i = 1; i <= n; i++) dis[i] = INF;
  dis[1] = 0LL;
  pq.push(make_pair(-dis[1], 1));
  long long ans = 0;
  while (!pq.empty()) {
    auto t = pq.top();
    pq.pop();
    int x = t.second;
    long long w = -t.first;
    nq[x] = 1;
    if (dis[x] != w) continue;
    for (int i = 2; i <= n; i++) {
      if (i == x) continue;
      if (nq[i]) continue;
      long long ww = myf(x, i);
      if (dis[i] > ww && ww < INF) {
        dis[i] = ww;
        pq.push(make_pair(-dis[i], i));
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (dis[i] != INF) ans += dis[i];
  }
  printf("%lld", ans);
  return 0;
}
