#include <bits/stdc++.h>
using namespace std;
long long minKey(long long key[], bool mstSet[], long long V) {
  long long min = INT_MAX, min_index;
  for (long long v = 0; v < V; v++)
    if (mstSet[v] == false && key[v] < min) min = key[v], min_index = v;
  return min_index;
}
long primMST(vector<long long> A, long long D, long long V) {
  long long graph[V][V];
  for (long long i = 0; i < V; i++) {
    for (long long j = i; j < V; j++) {
      graph[i][j] = abs(i - j) * D + A[i] + A[j];
      graph[j][i] = graph[i][j];
    }
  }
  long long parent[V];
  long long key[V];
  bool mstSet[V];
  for (long long i = 0; i < V; i++) key[i] = INT_MAX, mstSet[i] = false;
  key[0] = 0;
  parent[0] = -1;
  for (long long count = 0; count < V - 1; count++) {
    long long u = minKey(key, mstSet, V);
    mstSet[u] = true;
    for (long long v = 0; v < V; v++)
      if (graph[u][v] && mstSet[v] == false && graph[u][v] < key[v])
        parent[v] = u, key[v] = graph[u][v];
  }
  long c = 0;
  for (long long i = 1; i < V; i++) {
    c += graph[i][parent[i]];
  }
  return c;
}
int main() {
  long long N, D;
  cin >> N >> D;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  cout << primMST(A, D, N);
  return 0;
}
