#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
long long N, D;
long long nums[200009];
long long dp[200009];
long long ans = 0;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
void dfs(int cur) {
  ans += dp[cur];
  dp[cur] = -1;
  long long x = nums[cur];
  for (int i = 1; cur - i >= 0; i++) {
    int idx = cur - i;
    if (dp[idx] == -1) break;
    long long tmp = nums[idx] + x + i * D;
    if (dp[idx] > tmp) {
      dp[idx] = tmp;
      q.push({tmp, idx});
    }
  }
  for (int i = 1; cur + i < N; i++) {
    int idx = cur + i;
    if (dp[idx] == -1) break;
    long long tmp = nums[idx] + x + i * D;
    if (dp[idx] > tmp) {
      dp[idx] = tmp;
      q.push({tmp, idx});
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> D;
  for (int i = 0; i < N; i++) cin >> nums[i];
  for (int i = 0; i < N; i++) dp[i] = LLINF;
  int best;
  long long mn = LLINF;
  for (int i = 0; i < N; i++) {
    long long tmp = nums[i];
    if (mn > tmp) {
      mn = tmp;
      best = i;
    }
  }
  dp[best] = 0;
  q.push({0, best});
  while (q.size()) {
    auto a = q.top();
    q.pop();
    long long idx = a.second;
    long long x = a.first;
    if (dp[idx] < x)
      continue;
    else {
      dfs(idx);
    }
  }
  cout << ans << endl;
}
