#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "{";
  for (long long i = 0; i < (long long)v.size(); i++)
    o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
long long q, m, n, k, res, tmp, tmp2, tmp3;
long long a[200010] = {};
long long dist[100002];
deque<pair<long long, long long>> que;
string s;
vector<pair<long long, long long>> g[200010];
long long d;
class UnionFind {
 private:
  long long n;
  vector<long long> uni;

 public:
  UnionFind(long long _n) {
    n = _n;
    uni.clear();
    uni.resize(n, -1);
  }
  long long root(long long x) {
    if (uni[x] < 0) return x;
    return uni[x] = root(uni[x]);
  }
  bool same(long long x, long long y) { return root(x) == root(y); }
  void unite(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (uni[x] > uni[y]) swap(x, y);
    uni[x] += uni[y];
    uni[y] = x;
  }
  long long getSize(long long x) { return -uni[root(x)]; }
  void print() {
    for (auto x : uni) cout << x << " ";
    cout << endl;
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cin >> n >> d;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  res = 0;
  vector<pair<long long, pair<long long, long long>>> kore;
  UnionFind un(n);
  for (long long i = 0; i < n; i++) {
    if (i > 0) {
      kore.push_back({a[i] + d + a[i - 1], {i - 1, i}});
    }
    if (i < n - 1) {
      kore.push_back({a[i] + d + a[i + 1], {i + 1, i}});
    }
    for (long long j = i + 2; j < n; j++) {
      if (a[i] + (j - i) * d < a[j - 1] + d) {
        kore.push_back({a[i] + (j - i) * d + a[j], {j, i}});
      } else
        break;
    }
    for (long long j = i - 1 - 1; j >= 0; j--) {
      if (a[i] + (i - j) * d < a[j + 1] + d) {
        kore.push_back({a[i] + (i - j) * d + a[j], {j, i}});
      } else
        break;
    }
  }
  sort((kore).begin(), (kore).end());
  for (auto i : kore) {
    if (un.same(i.second.first, i.second.second)) {
      continue;
    }
    un.unite(i.second.first, i.second.second);
    res += i.first;
  }
  cout << res << endl;
}
