#include <bits/stdc++.h>
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
const int ms = 200200;
int par[ms];
int getPar(int x) { return x == par[x] ? x : par[x] = getPar(par[x]); }
bool makeUnion(int a, int b) {
  a = getPar(a), b = getPar(b);
  if (a == b) return false;
  par[a] = b;
  return true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n;
  long long d;
  std::cin >> n >> d;
  struct Edge {
    int u, v;
    long long c;
  };
  std::vector<int> a(n), p(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    p[i] = i;
  }
  std::sort(p.begin(), p.end(), [&](int v1, int v2) { return a[v1] < a[v2]; });
  auto getCost = [&](int i, int j) {
    return std::max(i - j, j - i) * d + a[i] + a[j];
  };
  std::vector<Edge> edges;
  int size = (int)(sqrt(n) + 10);
  size = std::min(size, n);
  for (int i = 0; i < n; i++) {
    int l = std::max(0, i - size);
    int r = std::min(n, i + size + 1);
    for (int j = l; j < r; j++) {
      int u = i, v = j;
      Edge e;
      e.u = u, e.v = v, e.c = getCost(u, v);
      edges.push_back(e);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < size; j++) {
      int u = i, v = p[j];
      Edge e;
      e.u = u, e.v = v, e.c = getCost(u, v);
      edges.push_back(e);
    }
  }
  std::sort(edges.begin(), edges.end(),
            [](Edge v1, Edge v2) { return v1.c < v2.c; });
  for (int i = 0; i < n; i++) {
    par[i] = i;
  }
  long long ans = 0;
  for (auto e : edges) {
    if (makeUnion(e.u, e.v)) {
      ans += e.c;
    }
  }
  std::cout << ans << '\n';
}
