#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); }
class UnionFind {
 private:
  vector<long long> rank, p;
  void makeSet(long long x) {
    p[x] = x;
    rank[x] = 0;
  }

 public:
  UnionFind(){};
  UnionFind(long long size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (long long i = 0; i < size; i++) {
      makeSet(i);
    }
  }
  bool same(long long x, long long y) { return find(x) == find(y); }
  void unite(long long x, long long y) { link(find(x), find(y)); }
  long long find(long long x) {
    if (x != p[x]) p[x] = find(p[x]);
    return p[x];
  }

 private:
  void link(long long x, long long y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
    }
  }
};
struct edge {
  long long from, to, cost;
  bool operator<(const edge& e) const { return cost < e.cost; }
};
long long kruskal(vector<edge> es, long long v) {
  sort(es.begin(), es.end());
  UnionFind uf(v);
  long long ret = 0;
  for (long long i = 0; i < es.size(); i++) {
    edge e = es[i];
    if (!uf.same(e.from, e.to)) {
      uf.unite(e.from, e.to);
      ret += e.cost;
    }
  }
  return ret;
}
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];
  vector<edge> e;
  for (long long i = 0; i < (n); i++)
    for (long long j = i + 1; j < (n); j++) {
      if (d == 1e9 && abs(i - j) > 100) continue;
      edge ee;
      ee.from = i;
      ee.to = j;
      ee.cost = abs(i - j) * d + a[i] + a[j];
      e.push_back(ee);
    }
  cout << kruskal(e, n) << endl;
}
