#include <bits/stdc++.h>
using namespace std;
long long int N, D;
const int MAXN = 200000;
long long int A[MAXN];
const long long int INF = 10000000000LL;
long long int solve(const vector<vector<long long int> >& C) {
  long long int left = N - 1;
  vector<int> visited(N, 0);
  visited[0] = 1;
  long long int res = 0;
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      Q;
  for (int i = 1; i < N; ++i) {
    Q.push(pair<long long int, long long int>(C[0][i],
                                              static_cast<long long int>(i)));
  }
  while (!Q.empty() && left != 0) {
    const auto cost = Q.top().first;
    const auto to = Q.top().second;
    Q.pop();
    if (visited[to]) {
      continue;
    }
    visited[to] = 1;
    --left;
    res += cost;
    if (left == 0) {
      break;
    }
    for (int i = 0; i < N; ++i)
      if (!visited[i]) {
        Q.push(pair<long long int, long long int>(
            C[to][i], static_cast<long long int>(i)));
      }
  }
  return res;
}
int main() {
  cin >> N >> D;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<vector<long long int> > C(N, vector<long long int>());
  for (int i = 0; i < N; ++i) {
    C[i].assign(N, 0LL);
  }
  for (int i = 0; i < N; ++i) {
    C[i][i] = INF;
  }
  for (int i = 0; i < N; ++i)
    for (int j = i + 1; j < N; ++j) {
      const long long int cost = abs(i - j) * D + A[i] + A[j];
      C[i][j] = C[j][i] = cost;
    }
  const long long int ans = solve(C);
  cout << ans << endl;
  return 0;
}
