#include <bits/stdc++.h>
using namespace std;
class union_find {
 private:
  vector<int> parent;
  vector<int> rank;

 public:
  union_find(int n) : parent(n), rank(n) {
    for (int i = 0; i < n; i++) parent[i] = i;
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
      parent[a] = b;
    } else {
      parent[b] = a;
      if (rank[a] == rank[b]) rank[a]++;
    }
  }
  int find(int a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
};
int main() {
  int n, d;
  cin >> n >> d;
  vector<int> a(n);
  for (auto &e : a) cin >> e;
  union_find u(n);
  vector<int> s(n, 1);
  vector<pair<int, int>> c(n);
  for (int i = 0; i < n; i++) {
    c[i].first = c[i].second = a[i];
  }
  long long r = 0;
  while (u.find(0) != u.find(n - 1)) {
    int mi = 0;
    long long mc = 1e16;
    for (int i = 0; i < n - 1; i++) {
      if (u.find(i) == u.find(i + 1)) {
        continue;
      }
      long long tc = c[u.find(i)].second + c[u.find(i + 1)].first + d;
      if (tc < mc) {
        mi = i;
        mc = tc;
      }
    }
    int u1 = u.find(mi), u2 = u.find(mi + 1);
    c[u1].first = min(c[u1].first, c[u2].first + d * s[u1]);
    c[u1].second = min(c[u1].second + d * s[u2], c[u2].second);
    s[u1] += s[u2];
    u.unite(mi, mi + 1);
    r += mc;
  }
  cout << r << endl;
}
