#include <bits/stdc++.h>
using namespace std;
const long MOD = 1e9 + 7;
struct edge {
  long to, cost;
};
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  UnionFind(int n) : par(n), rank(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank[x] > rank[y]) swap(x, y);
    par[x] = y;
    rank[y] += rank[x];
  }
  bool same(int x, int y) { return root(x) == root(y); }
};
struct Edge {
  long from, to, cost;
  bool operator<(const Edge &o) const { return cost < o.cost; }
};
struct Kruskal {
  int V;
  vector<Edge> edges;
  Kruskal(int v) { V = v; }
  long calc() {
    UnionFind uf(V);
    sort(edges.begin(), edges.end());
    long min_cost = 0L;
    for (Edge e : edges) {
      if (!uf.same(e.from, e.to)) {
        min_cost += e.cost;
        uf.unite(e.from, e.to);
      }
    }
    return min_cost;
  }
};
void solve() {
  long N, D;
  cin >> N >> D;
  priority_queue<pair<long, long>, vector<pair<long, long>>,
                 greater<pair<long, long>>>
      q;
  vector<edge> graph[2 * N];
  for (int i = 0; i < N; i++) {
    long A;
    cin >> A;
    if (i != N - 1) {
      graph[i + N].push_back({i + N + 1, D});
      graph[i + N + 1].push_back({i + N, D});
    }
    graph[i].push_back({i + N, A});
    graph[i + N].push_back({i, A});
    q.push({0, i});
  }
  Kruskal kruskal(N);
  vector<long> dist(2 * N, 1e18), par(2 * N, -1);
  for (int i = 0; i < N; i++) {
    par[i] = i;
    dist[i] = 0;
  }
  bitset<400040> vst;
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    long v = p.second, d = p.first;
    vst[v] = 1;
    dist[v] = d;
    for (auto e : graph[v]) {
      long nv = e.to;
      if (vst[nv]) {
        kruskal.edges.push_back({par[v], par[nv], dist[v] + dist[nv] + e.cost});
      } else {
        if (dist[nv] > d + e.cost) {
          par[nv] = par[v];
          dist[nv] = d + e.cost;
          q.push({d + e.cost, nv});
        }
      }
    }
  }
  cout << kruskal.calc() << endl;
}
int main(void) {
  solve();
  return 0;
}
