#include <bits/stdc++.h>
using namespace std;
const long long int E = 1e18 + 7;
const long long int MOD = 1000000007;
vector<long long int> uft;
long long int parent(long long int a) {
  if (uft[a] == a) {
    return a;
  }
  return uft[a] = parent(uft[a]);
}
void merge(long long int a, long long int b) { uft[parent(a)] = parent(b); }
int main() {
  long long int n, d;
  cin >> n >> d;
  vector<long long int> a(n);
  uft.resize(n);
  for (int i = 0; i < n; i++) {
    uft[i] = i;
  }
  for (auto &i : a) {
    cin >> i;
  }
  priority_queue<
      pair<long long int, pair<long long int, long long int>>,
      vector<pair<long long int, pair<long long int, long long int>>>,
      greater<pair<long long int, pair<long long int, long long int>>>>
      Q;
  set<pair<long long int, long long int>> second;
  second.insert({a[0], 0});
  for (int i = 1; i < n; i++) {
    long long int cnt = 0;
    for (auto I = second.begin(); I != second.end() && cnt < 20; ++I, cnt++) {
      Q.push({I->first + i * d + a[i], {I->second, i}});
    }
    second.insert({a[i] - i * d, i});
  }
  second.clear();
  second.insert({a.back(), n - 1});
  for (long long int i = n - 2; i >= 0; i--) {
    long long int cnt = 0;
    for (auto I = second.begin(); I != second.end() && cnt < 20; ++I, cnt++) {
      Q.push({I->first + (n - 1 - i) * d + a[i], {I->second, i}});
    }
    second.insert({a[i] - (n - 1 - i) * d, i});
  }
  long long int ans = 0;
  while (!Q.empty()) {
    pair<long long int, pair<long long int, long long int>> edge = Q.top();
    Q.pop();
    if (parent(edge.second.first) != parent(edge.second.second)) {
      merge(edge.second.first, edge.second.second);
      ans += edge.first;
    }
  }
  cout << ans << endl;
  return 0;
}
