#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 200010;
const long long inf = 1ll << 60;
long long n, D, a[Maxn];
long long fa[Maxn];
pair<long long, long long> seg[Maxn << 2], none;
long long ff(long long x) { return fa[x] == x ? x : fa[x] = ff(fa[x]); }
vector<long long> vec[Maxn];
struct lnode {
  long long x, y, d;
  bool operator<(const lnode &A) const { return d < A.d; }
} lis[Maxn << 1];
long long ll;
pair<long long, long long> _min(pair<long long, long long> x,
                                pair<long long, long long> y) {
  return x < y ? x : y;
}
pair<long long, long long> qry(long long now, long long L, long long R,
                               long long l, long long r) {
  if (l > r) return none;
  if (L == l && R == r) return seg[now];
  long long mid = L + R >> 1, lc = now << 1, rc = now << 1 | 1;
  if (r <= mid)
    return qry(lc, L, mid, l, r);
  else if (l > mid)
    return qry(rc, mid + 1, R, l, r);
  else
    return _min(qry(lc, L, mid, l, mid), qry(rc, mid + 1, R, mid + 1, r));
}
void chg(long long now, long long L, long long R, long long x, long long k) {
  if (L == R) {
    seg[now].first = k;
    return;
  }
  long long mid = L + R >> 1, lc = now << 1, rc = now << 1 | 1;
  if (x <= mid)
    chg(lc, L, mid, x, k);
  else
    chg(rc, mid + 1, R, x, k);
  seg[now] = _min(seg[lc], seg[rc]);
}
void build_tree1(long long now, long long L, long long R) {
  if (L < R) {
    long long mid = L + R >> 1, lc = now << 1, rc = now << 1 | 1;
    build_tree1(lc, L, mid);
    build_tree1(rc, mid + 1, R);
    seg[now] = _min(seg[lc], seg[rc]);
  } else {
    seg[now].first = a[L] - L * D;
    seg[now].second = L;
  }
}
void build_tree2(long long now, long long L, long long R) {
  if (L < R) {
    long long mid = L + R >> 1, lc = now << 1, rc = now << 1 | 1;
    build_tree2(lc, L, mid);
    build_tree2(rc, mid + 1, R);
    seg[now] = _min(seg[lc], seg[rc]);
  } else {
    seg[now].first = a[L] + L * D;
    seg[now].second = L;
  }
}
int main() {
  long long i, j, k;
  scanf("%lld%lld", &n, &D);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) fa[i] = i;
  none.first = inf;
  none.second = 0;
  long long sum = n, ans = 0;
  while (sum > 1) {
    for (i = 1; i <= n; i++) vec[i].clear();
    for (i = 1; i <= n; i++) vec[ff(i)].push_back(i);
    ll = 0;
    build_tree1(1, 1, n);
    for (i = 1; i <= n; i++) {
      if (vec[i].size() == 0) continue;
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        chg(1, 1, n, x, inf);
      }
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        pair<long long, long long> p = qry(1, 1, n, 1, x - 1);
        if (p.first != inf) {
          ll++;
          lis[ll].x = p.second;
          lis[ll].y = x;
          lis[ll].d = (x - p.second) * D + a[p.second] + a[x];
        }
      }
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        chg(1, 1, n, x, a[x] - x * D);
      }
    }
    build_tree2(1, 1, n);
    for (i = 1; i <= n; i++) {
      if (vec[i].size() == 0) continue;
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        chg(1, 1, n, x, inf);
      }
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        pair<long long, long long> p = qry(1, 1, n, x + 1, n);
        if (p.first != inf) {
          ll++;
          lis[ll].x = p.second;
          lis[ll].y = x;
          lis[ll].d = (p.second - x) * D + a[p.second] + a[x];
        }
      }
      for (j = 0; j < vec[i].size(); j++) {
        long long x = vec[i][j];
        chg(1, 1, n, x, a[x] + x * D);
      }
    }
    sort(lis + 1, lis + ll + 1);
    for (i = 1; i <= ll; i++) {
      long long fx = ff(lis[i].x), fy = ff(lis[i].y);
      if (fx != fy) {
        fa[fx] = fy;
        ans += lis[i].d;
      }
    }
    sum = 0;
    for (i = 1; i <= n; i++)
      if (fa[i] == i) sum++;
  }
  printf("%lld\n", ans);
  return 0;
}
