#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
long long mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
long long llmax = 9223372036854775807;
long long llmin = -9223372036854775807;
int iinf = intmax / 8;
long long inf = llmax / 8;
double eps = 1e-11;
int main() {
  long long N, D;
  cin >> N >> D;
  long long A[N];
  long long mina = inf;
  long long minnum = -1;
  for (long long i = (long long)0; i < (long long)N; i++) {
    cin >> A[i];
    if (A[i] < mina) {
      mina = A[i];
      minnum = i;
    }
  }
  long long ans = 0;
  long long cost = mina + D;
  for (long long i = (long long)minnum - 1; i > (long long)-1; i--) {
    ans += cost + A[i];
    cost = min(cost + D, A[i] + D);
  }
  cost = mina + D;
  for (long long i = (long long)minnum + 1; i < (long long)N; i++) {
    ans += cost + A[i];
    cost = min(cost + D, A[i] + D);
  }
  cout << ans << endl;
}
