#include <bits/stdc++.h>
using namespace std;
using T = tuple<long long, long long, long long>;
bool operator>(const T a, const T b) { return get<0>(a) > get<1>(b); };
class UnionFind {
 public:
  vector<long long> table;
  UnionFind(int size) { table.resize(size, -1); }
  int find(int x) {
    if (table[x] < 0)
      return x;
    else {
      table[x] = find(table[x]);
      return table[x];
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  bool is_root(int x) {
    if (table[x] < 0)
      return true;
    else
      return false;
  }
  void unite(int x, int y) {
    int r1 = find(x);
    int r2 = find(y);
    if (r1 != r2) {
      if (table[r1] > table[r2]) {
        table[r2] = r1;
        table[r1]--;
      } else {
        table[r1] = r2;
        table[r2]--;
      }
    }
    return;
  }
};
int main() {
  long long n, d;
  cin >> n >> d;
  vector<long long> a(n), cost_left_num(n), cost_left_id(n), cost_right_num(n),
      cost_right_id(n), limit_left(n), limit_right(n);
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a[i] = x;
    cost_left_num[i] = x;
    cost_right_num[i] = x;
  }
  UnionFind uf(n);
  iota(cost_left_id.begin(), cost_left_id.end(), 0);
  iota(cost_right_id.begin(), cost_right_id.end(), 0);
  iota(limit_left.begin(), limit_left.end(), 0);
  iota(limit_right.begin(), limit_right.end(), 0);
  priority_queue<T, vector<T>, greater<T> > q;
  for (int i = 0; i < n - 1; ++i) {
    T t0 = make_tuple(a[i] + a[i + 1], i, i + 1);
    q.push(t0);
  }
  int cnt = n;
  long long ans = 0;
  while (cnt > 1) {
    T l = q.top();
    q.pop();
    long long c = get<0>(l);
    long long i = get<1>(l);
    long long j = get<2>(l);
    if (uf.same(i, j))
      continue;
    else {
      cnt--;
      long long x = uf.find(i);
      long long y = uf.find(j);
      uf.unite(x, y);
      long long z = uf.find(x);
      ans += d + c;
      limit_right[z] = limit_right[y];
      limit_left[z] = limit_left[x];
      if (a[cost_left_id[x]] + d * (cost_left_id[x] - limit_left[z]) <=
          a[cost_left_id[y]] + d * (cost_left_id[y] - limit_left[z])) {
        cost_left_num[z] = cost_left_num[x];
        cost_left_id[z] = cost_left_id[x];
      } else {
        cost_left_num[z] =
            a[cost_left_id[y]] + d * (cost_left_id[y] - limit_left[z]);
        cost_left_id[z] = cost_left_id[y];
      }
      if (a[cost_right_id[y]] + d * (limit_right[z] - cost_right_id[y]) <=
          a[cost_right_id[x]] + d * (limit_right[z] - cost_right_id[x])) {
        cost_right_num[z] = cost_right_num[y];
        cost_right_id[z] = cost_right_id[y];
      } else {
        cost_right_num[z] =
            a[cost_right_id[x]] + d * (limit_right[z] - cost_right_id[x]);
        cost_right_id[z] = cost_right_id[x];
      }
      if (limit_left[z] > 0) {
        long long w = uf.find(limit_left[z] - 1);
        T t0 = make_tuple(cost_left_num[z] + cost_right_num[w], w, z);
        q.push(t0);
      }
      if (limit_right[z] < n - 1) {
        long long w = uf.find(limit_right[z] + 1);
        T t0 = make_tuple(cost_left_num[w] + cost_right_num[z], z, w);
        q.push(t0);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
