#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;
struct UnionFind {
  vector<long long int> uf;
  void init(long long int n) { uf.assign(n, -1); }
  int find(long long int x) {
    return uf[x] < 0 ? x : (uf[x] = this->find(uf[x]));
  }
  bool connect(long long int a, long long int b) {
    a = this->find(a);
    b = this->find(b);
    if (a != b) {
      uf[b] = a;
      return true;
    }
    return false;
  }
} uf;
struct Edge {
  long long int from, to, cost;
  Edge() {}
  Edge(long long int _from, long long int _to, long long int _cost)
      : from(_from), to(_to), cost(_cost) {}
  void input(long long int d = 0) {
    cin >> from >> to >> cost;
    from -= d;
    to -= d;
  }
  void set(long long int _from, long long int _to, long long int _cost) {
    from = _from;
    to = _to;
    cost = _cost;
  }
  const bool operator<(const Edge& e) const { return cost < e.cost; }
};
long long int kruscal(int n, vector<Edge>& edges) {
  long long int res = 0;
  sort(edges.begin(), edges.end());
  uf.init(n);
  for (int i = 0; i < edges.size(); ++i) {
    if (uf.connect(edges[i].from, edges[i].to)) {
      res += edges[i].cost;
    }
  }
  return res;
}
int main() {
  cin >> N >> D;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  vector<Edge> edges;
  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];
      edges.push_back(Edge(i, j, cost));
    }
  const long long int ans = kruscal(N, edges);
  cout << ans << endl;
  return 0;
}
