#include <bits/stdc++.h>
using i64 = long long;
class UF {
  int *par;
  int *rank;

 public:
  UF(int size) : par(new int[size]), rank(new int[size]()) {
    for (int i = 0; i < size; i++) par[i] = i;
  }
  ~UF() {
    delete[] par;
    delete[] rank;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) { return root(x) == root(y); }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank[x] < rank[y])
      par[x] = y;
    else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
};
int main() {
  int n;
  i64 d;
  std::cin >> n >> d;
  std::vector<i64> a(n);
  std::vector<std::pair<i64, int>> b, c;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    b.emplace_back(a[i] + i * d, i);
    c.emplace_back(a[i] - i * d, i);
  }
  for (int i = 1; i < n; i++) {
    b[n - 1 - i] = std::min(b[n - i - 1], b[n - i]);
    c[i] = std::min(c[i], c[i - 1]);
  }
  std::vector<std::tuple<i64, int, int>> cand;
  for (int i = 0; i < n; i++) {
    if (i) {
      int v = c[i - 1].second;
      cand.emplace_back(a[i] + a[v] + d * (i - v), i, v);
    }
    if (i + 1 < n) {
      int v = b[i + 1].second;
      cand.emplace_back(a[i] + a[v] + d * (v - i), i, v);
    }
  }
  std::sort(cand.begin(), cand.end());
  UF uft(n);
  i64 ret = 0;
  for (auto &e : cand) {
    int u = std::get<1>(e), v = std::get<2>(e);
    if (uft.same(u, v)) continue;
    uft.unite(u, v);
    ret += std::get<0>(e);
  }
  std::cout << ret << std::endl;
  return 0;
}
