#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, d, A[N];
long long D[N];
struct CMP {
  bool operator()(int a, int b) { return (A[a] + D[a] < A[b] + D[b]); }
};
set<int> P;
set<int, CMP> S;
inline void relax(int v) {
  printf("sfokds");
  auto it = P.begin();
  while (it != P.end()) {
    int u = *it;
    long long dist = abs(u - v) * 1LL * d + A[v];
    if (dist >= D[u]) break;
    S.erase(u);
    D[u] = dist;
    S.insert(u);
    it++;
  }
  it = P.end();
  while (it != P.begin()) {
    it--;
    int u = *it;
    long long dist = abs(u - v) * 1LL * d + A[v];
    if (dist >= D[u]) break;
    S.erase(u);
    D[u] = dist;
    S.insert(u);
  }
  it = P.lower_bound(v);
  while (it != P.end()) {
    int u = *it;
    long long dist = abs(u - v) * 1LL * d + A[v];
    if (dist >= D[u]) break;
    S.erase(u);
    D[u] = dist;
    S.insert(u);
    it++;
  }
  it = P.lower_bound(v);
  while (it != P.begin()) {
    it--;
    int u = *it;
    long long dist = abs(u - v) * 1LL * d + A[v];
    if (dist >= D[u]) break;
    S.erase(u);
    D[u] = dist;
    S.insert(u);
  }
}
int main() {
  scanf("%d%d", &n, &d);
  memset(D, 63, sizeof(D));
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]), S.insert(i), P.insert(i);
  P.erase(1);
  S.erase(1);
  relax(1);
  long long mst = 0;
  while (S.size()) {
    int v = *S.begin();
    mst += D[v] + A[v];
    S.erase(S.begin());
    P.erase(v);
    relax(v);
  }
  printf("%lld", mst);
  return (0);
}
