#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
struct UnionFind {
  int n, cc, *u;
  UnionFind() : n(0), cc(0), u(NULL) {}
  UnionFind(int n_) : n(n_), cc(n_) {
    u = new int[n_];
    memset(u, -1, sizeof(int) * n);
  }
  UnionFind(const UnionFind &y) : n(y.n), cc(y.cc) {
    u = new int[y.n];
    memcpy(u, y.u, sizeof(int) * n);
  }
  ~UnionFind() {
    delete[] u;
    u = NULL;
    n = cc = 0;
  }
  friend void swap(UnionFind &x, UnionFind &y) {
    swap(x.n, y.n);
    swap(x.cc, y.cc);
    swap(x.u, y.u);
  }
  UnionFind &operator=(UnionFind y) {
    swap(*this, y);
    return *this;
  }
  int root(int x) {
    int y = x, t;
    while (u[y] >= 0) y = u[y];
    while (x != y) {
      t = u[x];
      u[x] = y;
      x = t;
    }
    return y;
  }
  bool link(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (u[y] < u[x]) swap(x, y);
    u[x] += u[y];
    u[y] = x;
    cc--;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -u[root(x)]; }
  int count() { return cc; }
};
template <class T>
struct RMQ {
  int n;
  vector<T> A;
  vector<int> I;
  RMQ(int n_ = 0) : n(n_), A(n), I(2 * n) {
    for (int i = 0; i < n; i++) I[i + n] = i;
    for (int i = n; --i;) I[i] = I[2 * i];
  }
  RMQ(const vector<T> &a) : n(a.size()), A(a), I(2 * n) {
    for (int i = 0; i < n; i++) I[i + n] = i;
    for (int i = n; --i;)
      I[i] = (A[I[i * 2 + 1]] < A[I[i * 2]] ? I[i * 2 + 1] : I[i * 2]);
  }
  void modify(int i, const T &v) {
    A[i] = v;
    for (i += n; i >>= 1;)
      I[i] = (A[I[i * 2 + 1]] < A[I[i * 2]] ? I[i * 2 + 1] : I[i * 2]);
  }
  int min_i(int x, int y) {
    x += n;
    y += n;
    int p = -1;
    for (; x < y; x >>= 1, y >>= 1) {
      if (y & 1) {
        --y;
        if (p < 0 || A[I[y]] < A[p]) p = I[y];
      }
      if (x & 1) {
        if (p < 0 || A[I[x]] < A[p]) p = I[x];
        x++;
      }
    }
    return p;
  }
  T min_v(int x, int y) { return A[min_i(x, y)]; }
};
const int MAXN = 400011;
const long long INF = 1LL << 60;
int N;
long long D;
long long A[MAXN];
vector<int> G[MAXN];
void MAIN() {
  scanf("%d%lld", &N, &D);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%lld", A + i);
  UnionFind U(N);
  RMQ<long long> Fp(N), Fm(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    assert(1000000000 + i * D < INF);
    Fp.modify(i, A[i] + i * D);
    Fm.modify(i, A[i] - i * D);
    G[i].push_back(i);
  }
  long long ans = 0;
  while (U.count() > 1) {
    using Tuple = tuple<long long, int, int>;
    vector<Tuple> z;
    for (int i = 0, i_len = (N); i < i_len; ++i)
      if (U.root(i) == i) {
        for (__typeof((G[i]).begin()) e = (G[i]).begin(), e_end = (G[i]).end();
             e != e_end; ++e) {
          Fp.modify(*e, INF);
          Fm.modify(*e, INF);
        }
        for (__typeof((G[i]).begin()) e = (G[i]).begin(), e_end = (G[i]).end();
             e != e_end; ++e) {
          if (*e + 1 < N) {
            long long p = Fp.min_i(*e + 1, N);
            if (p != -1) {
              z.emplace_back((p - *e) * D + A[p] + A[*e], *e, p);
            }
          }
          if (0 < *e) {
            long long m = Fm.min_i(0, *e);
            if (m != -1) {
              z.emplace_back((*e - m) * D + A[m] + A[*e], *e, m);
            }
          }
        }
        for (__typeof((G[i]).begin()) e = (G[i]).begin(), e_end = (G[i]).end();
             e != e_end; ++e) {
          Fp.modify(*e, A[*e] + *e * D);
          Fm.modify(*e, A[*e] - *e * D);
        }
      }
    sort(z.begin(), z.end());
    for (__typeof((z).begin()) e = (z).begin(), e_end = (z).end(); e != e_end;
         ++e) {
      long long cst;
      int x, y;
      tie(cst, x, y) = *e;
      if (!U.same(x, y)) {
        ans += cst;
        x = U.root(x);
        y = U.root(y);
        U.link(x, y);
        int r = U.root(x);
        if (x == r)
          G[r].insert(G[r].end(), G[y].begin(), G[y].end());
        else
          G[r].insert(G[r].end(), G[x].begin(), G[x].end());
      }
    }
  }
  printf("%lld\n", ans);
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
