#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, D;
  cin >> N >> D;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int cost[N][N];
  int mincost[N];
  bool used[N];
  for (int i = 0; i < N; i++) {
    mincost[i] = INT_MAX;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;
  for (int u = 0; u < N; u++) {
    for (int v = 0; v < N; v++) {
      if (u == v) {
        cost[v][u] = INT_MAX;
      } else {
        cost[v][u] = abs(u - v) * D + A[u] + A[v];
      }
    }
  }
  while (true) {
    int v = -1;
    for (int u = 0; u < N; u++) {
      if (!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;
    res += mincost[v];
    for (int u = 0; u < N; u++) {
      mincost[u] = min(mincost[u], cost[v][u]);
    }
  }
  cout << res << endl;
  return 0;
}
