#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int lab[maxn], N;
int a[maxn], D;
vector<pair<int, pair<int, int>>> edge;
void init(int n) {
  for (int i = 1; i <= n; ++i) lab[i] = -1;
}
int finds(int u) {
  if (lab[u] < 0) return u;
  return lab[u] = finds(lab[u]);
}
bool merges(int u, int v) {
  u = finds(u);
  v = finds(v);
  if (u == v) return false;
  if (lab[v] < lab[u]) swap(u, v);
  lab[u] += lab[v];
  lab[v] = u;
  return true;
}
void solve(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) / 2;
  solve(l, mid);
  solve(mid + 1, r);
  int minl = -1, minr = -1;
  for (int i = l; i <= mid; ++i)
    if (minl == -1 ||
        1ll * D * (mid - i) + a[i] < 1ll * D * (mid - minl) + a[minl])
      minl = i;
  for (int i = mid + 1; i <= r; ++i)
    if (minr == -1 ||
        1ll * D * (i - mid) + a[i] < 1ll * D * (minr - mid) + a[minr])
      minr = i;
  for (int i = l; i <= mid; ++i)
    if (minr != -1)
      edge.emplace_back(1ll * D * (minr - i) + a[i] + a[minr],
                        make_pair(i, minr));
  for (int i = l + 1; i <= r; ++i)
    if (minl != -1)
      edge.emplace_back(1ll * D * (i - minl) + a[i] + a[minl],
                        make_pair(i, minl));
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> D;
  for (int i = 1; i <= N; ++i) cin >> a[i];
  solve(1, N);
  init(N);
  sort(edge.begin(), edge.end());
  long long res = 0;
  for (auto& all : edge) {
    if (merges(all.second.first, all.second.second)) {
      res += all.first;
    }
  }
  cout << res;
}
