#include <bits/stdc++.h>
using namespace std;
const int maxn = 200002;
int n, a[maxn];
long long D, f[maxn], ans, dist[maxn];
bool vis[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> D;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    f[i] = D * i;
  }
  vis[0] = true;
  for (int i = 1; i < n; ++i) dist[i] = f[i] + a[i] + a[0];
  for (int i = 1; i < n; ++i) {
    int idx = -1;
    long long mind = 1e15;
    for (int j = 1; j < n; ++j)
      if (!vis[j] && dist[j] < mind) {
        mind = dist[j];
        idx = j;
      }
    if (idx == -1) break;
    vis[idx] = true;
    ans += dist[idx];
    for (int j = 1; j < n; ++j)
      if (!vis[j] && dist[j] > f[abs(j - idx)] + a[j] + a[idx]) {
        dist[j] = f[abs(j - idx)] + a[j] + a[idx];
      }
  }
  cout << ans << endl;
  return 0;
}
