#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using str = string;
constexpr long long INF = (1LL << 60);
constexpr long long MOD = (1e9 + 7);
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return (gcd(b, a % b));
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline void dump() { cout << endl; }
template <class Head, class... Tail>
inline void dump(Head &&head, Tail &&...tail) {
  cout << head << ", ";
  dump(forward<Tail>(tail)...);
}
template <typename T>
inline istream &operator>>(istream &input, vector<T> &v) {
  for (auto &elemnt : v) input >> elemnt;
  return input;
}
template <typename T>
class Union_Find {
 private:
  T n;
  vector<T> parent;

 public:
  Union_Find(T v) {
    n = v;
    parent.resize(n, -1);
  }
  T root(T v) {
    if (parent[v] < 0) return v;
    return parent[v] = root(parent[v]);
  }
  T size(T v) { return -parent[root(v)]; }
  bool connect(T a, T b) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    if (size(a) < size(b)) swap(a, b);
    parent[a] += parent[b];
    parent[b] = a;
    return true;
  }
  bool same(T a, T b) { return root(a) == root(b); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  ll n, d;
  cin >> n >> d;
  vector<ll> a(n);
  cin >> a;
  vector<pair<ll, ll>> b;
  for (ll i = 0; i < (n); ++i) {
    b.emplace_back(a[i], i);
  }
  sort(b.begin(), b.end());
  using edge = struct edge {
    ll from, to, cost;
    edge(ll a, ll b, ll c) : from(a), to(b), cost(c) {}
    bool operator<(const edge &_) const { return cost < _.cost; }
  };
  vector<edge> edges;
  for (ll i = 0; i < (n - 1); ++i) {
    edges.emplace_back(i, i + 1, a[i] + a[i + 1] + d);
  }
  for (ll i = 0; i < (n); ++i) {
    for (ll j = i + 1; j < (i + 100) && j < n; ++j) {
      ll x, y;
      x = b[i].second;
      y = b[i].second;
      edges.emplace_back(x, y, abs(x - y) * d + b[i].first + b[j].first);
    }
  }
  sort(edges.begin(), edges.end());
  Union_Find<ll> uni(n);
  ll res = 0, cnt = 0;
  for (const edge &e : edges) {
    if (uni.same(e.from, e.to)) continue;
    uni.connect(e.from, e.to);
    res += e.cost;
    cnt++;
  }
  if (cnt == n - 1) {
    cout << (res) << endl;
    return 0;
  }
}
