#include <bits/stdc++.h>
using namespace std;
double dot(complex<double> a, complex<double> b) {
  return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
  return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
  double cosine = dot(a, b) / (leng(a) * leng(b));
  double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
  double kaku = acos(cosine);
  if (sine <= 0) {
    kaku = 2 * 3.141592653589793 - kaku;
  }
  return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
  vector<int> ans;
  double now_minnest = a[0].real();
  int now_itr = 0;
  for (long long i = 0; i < a.size(); ++i) {
    if (now_minnest > a[i].real()) {
      now_minnest = a[i].real();
      now_itr = i;
    }
  }
  ans.push_back(now_itr);
  complex<double> ba(0, 1);
  while (true) {
    int now_go = 0;
    double now_min = 0;
    int starter = ans[ans.size() - 1];
    for (int i = 0; i < a.size(); ++i) {
      if (i != starter) {
        double goa = angles(ba, a[i] - a[starter]);
        if (goa > now_min) {
          now_min = goa;
          now_go = i;
        }
      }
    }
    if (now_go == ans[0]) break;
    ans.push_back(now_go);
    ba = complex<double>(a[now_go] - a[starter]);
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
pair<long long, long long> seg_tree[2][524288 * 2 + 1];
pair<long long, long long> seg_find(long long now, long long w_l, long long w_r,
                                    long long n_l, long long n_r,
                                    long long setting) {
  if (w_l <= n_l && n_r <= w_r) return seg_tree[setting][now];
  if (w_r <= n_l || n_r <= w_l) return make_pair(3e18, -1);
  pair<long long, long long> a =
      seg_find(now * 2, w_l, w_r, n_l, (n_l + n_r) / 2, setting);
  pair<long long, long long> b =
      seg_find(now * 2 + 1, w_l, w_r, (n_l + n_r) / 2, n_r, setting);
  if (a.first < b.first)
    return a;
  else
    return b;
}
void seg_set(long long now) {
  for (long long q = 0; q < 2; ++q) {
    if (seg_tree[q][now * 2].first < seg_tree[q][now * 2 + 1].first) {
      seg_tree[q][now] = seg_tree[q][now * 2];
    } else {
      seg_tree[q][now] = seg_tree[q][now * 2 + 1];
    }
  }
  if (now != 1) seg_set(now / 2);
  return;
}
vector<tuple<long long, long long, long long>> edges;
long long union_find[300000] = {};
long long union_search(long long a) {
  if (union_find[a] == a) return a;
  return union_find[a] = union_search(union_find[a]);
}
long long union_merge(long long a, long long b) {
  a = union_search(a);
  b = union_search(b);
  union_find[a] = b;
  return 0;
}
int main() {
  iostream::sync_with_stdio(false);
  long long n, d;
  cin >> n >> d;
  vector<long long> inputs;
  for (long long i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    inputs.push_back(a);
  }
  for (long long i = 0; i < 2; ++i) {
    for (long long q = 0; q < 524288 * 2 + 1; ++q) {
      seg_tree[i][q] = make_pair(3e18, -1);
    }
  }
  for (long long q = 0; q < inputs.size(); ++q) {
    seg_tree[0][q + 524288] = make_pair(inputs[q] + q * d, q);
    seg_tree[1][q + 524288] =
        make_pair(inputs[q] + ((long long)inputs.size() - q) * d, q);
    seg_set((q + 524288) / 2);
  }
  for (long long i = 0; i < n - 1; ++i) {
    pair<long long, long long> now = seg_find(1, i + 1, 524288, 0, 524288, 0);
    long long costs = now.second - i;
    costs *= d;
    costs += inputs[i];
    costs += inputs[now.second];
    edges.push_back(make_tuple(costs, i, now.second));
  }
  for (long long i = 1; i < n; ++i) {
    pair<long long, long long> now = seg_find(1, 0, i, 0, 524288, 1);
    long long costs = i - now.second;
    costs *= d;
    costs += inputs[i];
    costs += inputs[now.second];
    edges.push_back(make_tuple(costs, i, now.second));
  }
  sort(edges.begin(), edges.end());
  long long ans = 0;
  for (long long i = 0; i < 300000; ++i) {
    union_find[i] = i;
  }
  for (long long i = 0; i < edges.size(); ++i) {
    long long a = get<1>(edges[i]);
    long long b = get<2>(edges[i]);
    if (union_search(a) != union_search(b)) {
      union_merge(a, b);
      ans += get<0>(edges[i]);
    }
  }
  cout << ans << endl;
}
