#include <bits/stdc++.h>
using namespace std;
int N, uf[200000];
long long D, A[200000], res;
pair<long long, int> Min;
priority_queue<pair<long long, pair<int, int>>,
               vector<pair<long long, pair<int, int>>>,
               greater<pair<long long, pair<int, int>>>>
    q;
int TOP(int x) {
  if (uf[x] < 0)
    return x;
  else
    return uf[x] = TOP(uf[x]);
}
bool UNION(int x, int y) {
  x = TOP(x);
  y = TOP(y);
  if (x == y) {
    return false;
  }
  if (x < y) {
    uf[x] += uf[y];
    uf[y] = x;
  } else {
    uf[y] += uf[x];
    uf[x] = y;
  }
  return true;
}
int main() {
  cin >> N >> D;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    uf[i] = -1;
  }
  Min = make_pair(A[0], 0);
  for (int i = 1; i < N; ++i) {
    Min.first += D;
    q.push(make_pair(Min.first + A[i], make_pair(Min.second, i)));
    Min = min(Min, make_pair(A[i], i));
  }
  Min = make_pair(A[N - 1], N - 1);
  for (int i = N - 2; i >= 0; --i) {
    Min.first += D;
    q.push(make_pair(Min.first + A[i], make_pair(i, Min.second)));
    Min = min(Min, make_pair(A[i], i));
  }
  while (!q.empty()) {
    if (UNION(q.top().second.first, q.top().second.second)) {
      res += q.top().first;
    }
    q.pop();
  }
  cout << res << endl;
  return 0;
}
