#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
class union_find {
 private:
  vector<int> parent, rank, gs;
  int size;

 public:
  int count_group;
  union_find() = default;
  union_find(int n) { init(n); }
  void init(int n) {
    size = n;
    count_group = n;
    parent.resize(size);
    rank.assign(size, 0);
    gs.assign(size, 1);
    for (int i = 0; i < size; ++i) parent[i] = i;
  }
  int find(int x) {
    if (parent[x] == x)
      return x;
    else
      return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      parent[x] = y;
      gs[y] += gs[x];
    } else {
      parent[y] = x;
      gs[x] += gs[y];
      if (rank[x] == rank[y]) ++rank[x];
    }
    --count_group;
  }
  bool is_same_group(int x, int y) { return find(x) == find(y); }
  int group_size(int x) { return gs[find(x)]; };
};
void solve() {
  i64 N, D;
  cin >> N >> D;
  vector<i64> A(N);
  set<pair<i64, i64>> ai;
  for (i64 i = i64(0), i_max_for_repmacro = i64(N); i < i_max_for_repmacro;
       ++i) {
    cin >> A[i];
    ai.insert(make_pair(A[i], i));
  }
  union_find uf(N);
  priority_queue<pair<i64, i64>, vector<pair<i64, i64>>,
                 greater<pair<i64, i64>>>
      pq;
  i64 ans = 0;
  set<i64> done;
  while (true) {
    i64 u;
    if (pq.empty()) {
      u = 0;
      done.insert(u);
      for (i64 v = i64(1), v_max_for_repmacro = i64(N); v < v_max_for_repmacro;
           ++v) {
        pq.push(make_pair(D * abs(u - v) + A[u] + A[v], v));
      }
      continue;
    }
    auto p = pq.top();
    pq.pop();
    u = p.second;
    if (done.find(u) != done.end()) continue;
    ;
    ans += p.first;
    done.insert(u);
    if (done.size() == N) break;
    i64 x;
    {
      while (true) {
        auto tmp = pq.top();
        if (done.find(tmp.second) != done.end()) {
          pq.pop();
          continue;
        }
        x = tmp.first;
        break;
      }
    }
    vector<pair<i64, i64>> del;
    for (auto &tmp : ai) {
      if (done.find(tmp.second) != done.end()) {
        del.push_back(tmp);
        continue;
      }
      i64 v = tmp.second;
      if (A[u] + A[v] > x) break;
      pq.push(make_pair(D * abs(u - v) + A[u] + A[v], v));
    }
    for (auto &tmp : del) ai.erase(tmp);
    for (i64 k = i64(1), k_max_for_repmacro = i64(N); k < k_max_for_repmacro;
         ++k) {
      if (D * k + A[u] > x) break;
      if (u - k >= 0) {
        i64 v = u - k;
        i64 cost = D * abs(u - v) + A[u] + A[v];
        if (cost <= x) pq.push(make_pair(cost, v));
      }
      if (u + k < N) {
        i64 v = u + k;
        i64 cost = D * abs(u - v) + A[u] + A[v];
        if (cost <= x) pq.push(make_pair(cost, v));
      }
    }
  }
  cout << ans << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
