#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
const long long INF = 1e18;
long long ans;
int n, D, a[1100010];
struct node {
  long long c;
  int y, x;
  node() {}
  node(long long C, int Y, int X) { c = C, y = Y, x = X; }
  bool operator>(const node &A) const { return (c < A.c); }
  bool operator<(const node &A) const { return (c > A.c); }
};
priority_queue<node> Q;
bool u[1100010];
namespace T1 {
pair<long long, int> T[800010];
void build(int l, int r, int rt) {
  if (l == r) {
    T[rt] = make_pair(a[l] - 1ll * l * D, l);
    return;
  }
  int m = l + r >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  T[rt] = min(T[rt << 1], T[rt << 1 | 1]);
}
void upd(int l, int r, int rt, int x, long long y) {
  if (l == r) {
    T[rt] = make_pair(y, x);
    return;
  }
  int m = l + r >> 1;
  if (x <= m)
    upd(l, m, rt << 1, x, y);
  else
    upd(m + 1, r, rt << 1 | 1, x, y);
  T[rt] = min(T[rt << 1], T[rt << 1 | 1]);
}
pair<long long, int> que(int l, int r, int rt, int L, int R) {
  if (T[rt].first >= INF) return T[rt];
  if (l >= L && r <= R) return T[rt];
  int m = l + r >> 1;
  pair<long long, int> t = make_pair(INF, 0);
  if (L <= m) t = min(t, que(l, m, rt << 1, L, R));
  if (R > m) t = min(t, que(m + 1, r, rt << 1 | 1, L, R));
  return t;
}
};  // namespace T1
namespace T2 {
pair<long long, int> T[800010];
void build(int l, int r, int rt) {
  if (l == r) {
    T[rt] = make_pair(a[l] + 1ll * l * D, l);
    return;
  }
  int m = l + r >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  T[rt] = min(T[rt << 1], T[rt << 1 | 1]);
}
void upd(int l, int r, int rt, int x, long long y) {
  if (l == r) {
    T[rt] = make_pair(y, x);
    return;
  }
  int m = l + r >> 1;
  if (x <= m)
    upd(l, m, rt << 1, x, y);
  else
    upd(m + 1, r, rt << 1 | 1, x, y);
  T[rt] = min(T[rt << 1], T[rt << 1 | 1]);
}
pair<long long, int> que(int l, int r, int rt, int L, int R) {
  if (T[rt].first >= INF) return T[rt];
  if (l >= L && r <= R) return T[rt];
  int m = l + r >> 1;
  pair<long long, int> t = make_pair(INF, 0);
  if (L <= m) t = min(t, que(l, m, rt << 1, L, R));
  if (R > m) t = min(t, que(m + 1, r, rt << 1 | 1, L, R));
  return t;
}
};  // namespace T2
void ins(int x, int tp) {
  if (tp == 1) {
    if (x > 1) {
      pair<long long, int> tmp = T1::que(1, n, 1, 1, x - 1);
      if (tmp.first >= INF) return;
      if (tmp.second < 1 || tmp.second > n || u[tmp.second]) return;
      tmp.first += 1ll * x * D + a[x];
      Q.push(node(tmp.first, tmp.second, x));
    }
  } else {
    if (x < n) {
      pair<long long, int> tmp = T2::que(1, n, 1, x + 1, n);
      if (tmp.first >= INF) return;
      if (tmp.second < 1 || tmp.second > n || u[tmp.second]) return;
      tmp.first += a[x] - 1ll * x * D;
      Q.push(node(tmp.first, tmp.second, x));
    }
  }
}
void prim() {
  T1::build(1, n, 1);
  T2::build(1, n, 1);
  u[1] = 1;
  T1::upd(1, n, 1, 1, INF);
  T2::upd(1, n, 1, 1, INF);
  ins(1, 1);
  ins(1, 2);
  while (!Q.empty()) {
    node t = Q.top();
    Q.pop();
    long long c = t.c;
    int y = t.y;
    int x = t.x;
    int tp = 2;
    if (x > y) tp = 1;
    if (u[y]) {
      ins(x, tp);
      continue;
    }
    u[y] = 1;
    ans += c;
    T1::upd(1, n, 1, y, INF);
    T2::upd(1, n, 1, y, INF);
    ins(x, tp);
    ins(y, 1);
    ins(y, 2);
  }
}
int main() {
  cin >> n >> D;
  for (int i = 1; i <= n; ++i) getint(a[i]);
  prim();
  cout << ans << endl;
  return 0;
}
