#include <bits/stdc++.h>
using namespace std;
long long run();
int main() {
  cout.precision(15);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  run();
  return 0;
}
long long n, d, m;
long long a[200005], pre[200005];
struct edge {
  long long u, v;
  long long w;
  edge() {}
  edge(long long u, long long v, long long w) : u(u), v(v), w(w) {}
  bool operator<(const edge &other) const { return w < other.w; }
};
edge edges[200005 * 30];
void add(long long l, long long r) {
  if (l == r) return;
  long long mid = (l + r) >> 1;
  long long min = LLONG_MAX;
  long long pos = -1;
  for (long long i = l; i <= mid; i++) {
    long long f = a[i] - i * d;
    if (f < min) {
      min = f;
      pos = i;
    }
  }
  for (long long i = mid + 1; i <= r; i++) {
    edges[m++] = edge(pos, i, (i - pos) * d + a[i] + a[pos]);
  }
  min = LLONG_MAX;
  pos = -1;
  for (long long i = mid + 1; i <= r; i++) {
    long long f = a[i] + i * d;
    if (f < min) {
      min = f;
      pos = i;
    }
  }
  for (long long i = l; i <= mid; i++) {
    edges[m++] = edge(pos, i, a[pos] + a[i] + d * (pos - i));
  }
  add(l, mid);
  add(mid + 1, r);
}
long long find(long long x) {
  if (0 == pre[x]) return x;
  return pre[x] = find(pre[x]);
}
long long kruskal() {
  memset(pre, 0, sizeof(pre));
  sort(edges + 1, edges + m + 1);
  long long cnt = 1;
  long long res = 0;
  for (long long i = 1; i <= m; i++) {
    long long u = edges[i].u;
    long long v = edges[i].v;
    long long w = edges[i].w;
    long long fu = find(u);
    long long fv = find(v);
    if (fu == fv) continue;
    pre[fu] = fv;
    res += w;
    ++cnt;
    if (cnt == n) return res;
  }
  return res;
}
long long run() {
  cin >> n >> d;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  add(1, n);
  cout << kruskal();
}
