#include <bits/stdc++.h>
void read(int &x) {
  x = 0;
  int flag = 1;
  char ch = ' ';
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= flag;
}
void read(long long &x) {
  x = 0;
  int flag = 1;
  char ch = ' ';
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= flag;
}
using namespace std;
const int maxn = 200010;
struct Edge {
  int u, v, w;
  Edge() {}
  Edge(int a, int b, int c) { u = a, v = b, w = c; }
  bool operator<(const Edge &a) const { return w < a.w; }
};
vector<Edge> edge;
int n, f[maxn];
long long d, a[maxn];
int find(int x) { return f[x] == x ? f[x] : f[x] = find(f[x]); }
void solve(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1, px = 0, py = 0;
  long long x = 1e9, y = 1e9;
  x *= maxn;
  y *= maxn;
  for (int i = l; i <= mid; i++)
    if (a[i] - i * d <= x) {
      x = a[i] - i * d;
      px = i;
    }
  for (int i = mid + 1; i <= r; i++)
    if (a[i] + i * d <= y) {
      y = a[i] + i * d;
      py = i;
    }
  for (int i = l; i <= mid; i++)
    edge.push_back(Edge(i, py, (py - i) * d + a[i] + a[py]));
  for (int i = mid + 1; i <= r; i++)
    edge.push_back(Edge(px, i, (i - px) * d + a[px] + a[i]));
  solve(l, mid);
  solve(mid + 1, r);
}
int main() {
  read(n), read(d);
  for (int i = 1; i <= n; i++) read(a[i]);
  solve(1, n);
  sort(edge.begin(), edge.end());
  long long ans = 0;
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 0; i <= edge.size() - 1; i++) {
    int u = edge[i].u, v = edge[i].v;
    int root1 = find(u), root2 = find(v);
    if (root1 != root2) {
      f[root1] = root2;
      ans += edge[i].w;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
