#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
struct UnionFind {
  vector<long long> data;
  UnionFind(long long size) : data(size, -1) {}
  bool unionSet(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return 0;
    if (data[y] < data[x]) swap(x, y);
    data[x] += data[y], data[y] = x;
    return 1;
  }
  bool findSet(long long x, long long y) { return root(x) == root(y); }
  long long root(long long x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  long long size(long long x) { return -data[root(x)]; }
};
class KRK {
 public:
  struct edge {
    long long from, to, cost;
  };
  vector<edge> G;
  long long n;
  KRK(long long size) { n = size; }
  void add_edge(long long a, long long b, long long c) {
    edge e = {a, b, c};
    G.push_back(e);
  }
  long long krk() {
    long long sum = 0;
    sort(G.begin(), G.end(), [](edge a, edge b) { return a.cost < b.cost; });
    UnionFind uf(n);
    for (long long i = 0; i < (G.size()); i++) {
      edge e = G[i];
      if (!uf.findSet(e.from, e.to)) {
        sum += e.cost;
        uf.unionSet(e.from, e.to);
      }
    }
    return sum;
  }
};
signed main(void) {
  long long i, j;
  long long n, d;
  cin >> n >> d;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  KRK krk(n);
  for (long long i = 0; i < (n); i++)
    for (long long j = i + 1; j < (n); j++) {
      krk.add_edge(i, j, abs(i - j) * d + a[i] + a[j]);
    }
  cout << krk.krk() << endl;
}
