#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 666666;
int n, d, a[N];
long long res;
set<pair<long long, long long> > Set;
bool vis[N];
long long dis[N];
int main() {
  read(n);
  read(d);
  for (register int i = 1; i <= n; i++) read(a[i]);
  vis[1] = 1;
  for (register int i = 1; i <= n; i++)
    dis[i] = a[1] + a[i] + 1LL * (i - 1) * d;
  for (register int i = 2; i <= n; i++)
    Set.insert(pair<long long, long long>(dis[i], i));
  for (register int t = 1; t <= n - 1; t++) {
    int u = (*Set.begin()).second;
    Set.erase(Set.begin());
    res += dis[u];
    vis[u] = 1;
    for (register int i = u + 1; i <= n; i++) {
      if (a[u] + a[i] + 1LL * d * (i - u) >= dis[i]) break;
      if (!vis[i]) {
        Set.erase(pair<long long, long long>(dis[i], i));
        Set.insert(
            pair<long long, long long>(a[u] + a[i] + 1LL * d * (i - u), i));
      }
      dis[i] = a[u] + a[i] + 1LL * d * (i - u);
    }
    for (register int i = u - 1; i >= 1; i--) {
      if (a[u] + a[i] + 1LL * d * (u - i) >= dis[i]) break;
      if (!vis[i]) {
        Set.erase(pair<long long, long long>(dis[i], i));
        Set.insert(
            pair<long long, long long>(a[u] + a[i] + 1LL * d * (u - i), i));
      }
      dis[i] = a[u] + a[i] + 1LL * d * (u - i);
    }
  }
  cout << res;
  return 0;
}
