#include <bits/stdc++.h>
using namespace std;
static const int INF = 1e9;
static const int SIZE = 200001;
struct edge {
  int to;
  int cost;
};
bool isUsed[SIZE];
vector<edge> G[SIZE];
void solve() {
  int N, D;
  cin >> N >> D;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        continue;
      }
      edge e1, e2;
      e1.to = j;
      e1.cost = abs(i - j) * D + A[i] + A[j];
      e2.to = i;
      e2.cost = e1.cost;
      G[i].push_back(e1);
      G[j].push_back(e2);
    }
  }
  memset(isUsed, 0, sizeof(isUsed));
  int ans = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pque;
  pque.push(pair<int, int>(0, 0));
  while (!pque.empty()) {
    pair<int, int> p = pque.top();
    pque.pop();
    int v = p.second;
    if (isUsed[v]) {
      continue;
    }
    isUsed[v] = true;
    ans += p.first;
    for (int i = 0; i < G[v].size(); ++i) {
      edge e = G[v][i];
      pque.push(pair<int, int>(e.cost, e.to));
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return (0);
}
