#include <bits/stdc++.h>
using std::priority_queue;
using std::vector;
const int maxn = 2e5 + 2;
long long n, d, a[maxn], val[maxn], pre[maxn], suf[maxn], m, b[maxn], s[maxn];
long long fa[maxn];
inline long long find(long long x) {
  return (fa[x] == x) ? x : fa[x] = find(fa[x]);
}
struct Node {
  long long l, rk, val, tid;
  inline bool operator<(Node mlgb) const { return mlgb.val < val; }
} tp;
priority_queue<Node> q;
long long T[maxn], ls[maxn << 5], rs[maxn << 5], cnt[maxn << 5], idx, l, r,
    qval, rk, add, fx, fy, ans, edge;
long long id[maxn << 5];
inline void build(long long &rt, long long l, long long r) {
  rt = ++idx;
  cnt[rt] = 0;
  if (l == r) return;
  build(ls[rt], l, ((l + r) >> 1));
  build(rs[rt], ((l + r) >> 1) + 1, r);
}
inline void insert(long long &rt, long long pre, long long l, long long r,
                   long long k, long long pos) {
  rt = ++idx;
  cnt[rt] = cnt[pre] + 1;
  ls[rt] = ls[pre];
  rs[rt] = rs[pre];
  if (l == r) return (void)(id[rt] = pos);
  if (k <= ((l + r) >> 1))
    insert(ls[rt], ls[pre], l, ((l + r) >> 1), k, pos);
  else
    insert(rs[rt], rs[pre], ((l + r) >> 1) + 1, r, k, pos);
}
inline long long query(long long rt, long long l, long long r, long long k) {
  if (l == r) return id[rt];
  if (cnt[ls[rt]] < k)
    return query(rs[rt], ((l + r) >> 1) + 1, r, k - cnt[ls[rt]]);
  else
    return query(ls[rt], l, ((l + r) >> 1), k);
}
signed main() {
  scanf("%lld %lld", &n, &d);
  for (long long i = 1; i <= n; i++) fa[i] = i;
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) val[i] = a[i] + i * d, b[i] = val[i];
  std::sort(b + 1, b + n + 1);
  m = std::unique(b + 1, b + n + 1) - b - 1;
  for (long long i = 1; i <= n; i++)
    s[i] = std::lower_bound(b + 1, b + m + 1, val[i]) - b;
  build(T[n + 1], 1, m);
  for (long long i = n; i >= 1; i--) insert(T[i], T[i + 1], 1, m, s[i], i);
  for (long long i = 1; i <= n - 1; i++) {
    l = i;
    r = query(T[i + 1], 1, m, 1);
    add = a[i] - i * d;
    q.push((Node){l, 1, b[s[r]] + add, r});
  }
  while (!q.empty()) {
    tp = q.top();
    q.pop();
    fx = find(tp.l);
    fy = find(tp.tid);
    if (fx != fy) {
      ans += tp.val;
      fa[fy] = fx;
      edge++;
      if (edge == (n - 1)) break;
    }
    if ((tp.l + tp.rk) == n) continue;
    r = query(T[tp.l + 1], 1, m, tp.rk + 1);
    add = a[tp.l] - tp.l * d;
    q.push((Node){tp.l, tp.rk + 1, b[s[r]] + add, r});
  }
  printf("%lld", ans);
}
