#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int maxn = 1e5 + 5;
struct Edge {
  long long w;
  int u;
  int v;
  Edge(long long w, int u, int v) : w(w), u(u), v(v) {}
  inline bool operator<(const Edge &b) const { return w < b.w; }
};
class Dsu {
 private:
  int sz;
  int fa[maxn];

 public:
  inline void init(int n) {
    sz = n;
    for (int i = (0); i < (sz); ++i) fa[i] = i;
    return;
  }
  inline int find(int x) { return (x == fa[x]) ? (x) : (fa[x] = find(fa[x])); }
  inline void combine(int x, int y) {
    x = find(x);
    y = find(y);
    fa[x] = y;
    return;
  }
} dsu;
int n;
int a[maxn];
long long d, ans;
vector<Edge> vec;
inline void solve(int l, int r) {
  if (l >= r) return;
  int md = (l + r) >> 1;
  solve(l, md);
  solve(md + 1, r);
  int va = r, vs = l;
  for (int i = (l + 1); i <= (md); ++i)
    if (a[i] - d * i <= a[vs] - d * i) vs = i;
  for (int i = (md + 1); i < (r); ++i)
    if (a[i] + d * i <= a[va] + d * i) va = i;
  for (int i = (l); i <= (md); ++i)
    vec.push_back(Edge((va - i) * d + a[va] + a[i], va, i));
  for (int i = (md + 1); i <= (r); ++i)
    vec.push_back(Edge((i - vs) * d + a[vs] + a[i], vs, i));
  return;
}
int main() {
  scanf("%d%lld", &n, &d);
  for (int i = (0); i < (n); ++i) scanf("%d", a + i);
  solve(0, n - 1);
  sort(vec.begin(), vec.end());
  dsu.init(n);
  for (int i = (0); i < (vec.size()); ++i) {
    int u = vec[i].u, v = vec[i].v;
    if (dsu.find(u) == dsu.find(v)) continue;
    ans += vec[i].w;
    dsu.combine(u, v);
  }
  printf("%lld\n", ans);
  return 0;
}
