#include <bits/stdc++.h>
using namespace std;
int N;
long long D;
long long A[200000 + 1];
vector<pair<long long, pair<int, int> > > Edges;
struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }
  int root(int x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  int size(int x) { return -par[root(x)]; }
};
int main() {
  cin >> N >> D;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      Edges.push_back(make_pair(abs(i - j) * D + A[i] + A[j], make_pair(i, j)));
    }
  }
  sort(Edges.begin(), Edges.end());
  UnionFind uf(N);
  long long ans = 0;
  for (int i = 0; i < Edges.size(); i++) {
    pair<long long, pair<int, int> > e = Edges[i];
    if (!uf.issame(e.second.first, e.second.second)) {
      uf.merge(e.second.first, e.second.second);
      ans += e.first;
    }
  }
  cout << ans << endl;
  return 0;
}
