#include <numeric>
#include <queue>
#include <limits>
#include <vector>
#include <iostream>
#include <cassert>
#define NDEBUG
//!=======================================================================================!//
//!   a88888b.                     dP       .88888.                             dP        !//
//!  d8'   '88                     88      d8'   '88                            88        !//
//!  88        .d8888b. .d8888b. d8888P    88        88d888b. .d8888b. 88d888b. 88d888b.  !//
//!  88        88'  '88 Y8ooooo.   88      88   YP88 88'  '88 88'  '88 88'  '88 88'  '88  !//
//!  Y8.   .88 88.  .88       88   88      Y8.   .88 88       88.  .88 88.  .88 88    88  !//
//!   Y88888P' '88888P' '88888P'   dP       '88888'  dP       '88888P8 88Y888P' dP    dP  !//
//!                                                                    88                 !//
//!                                                                    dP                 !//
//!=======================================================================================!//
template <typename T>
struct CostGraph
{
    CostGraph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const std::size_t from, const std::size_t to, const T cost, const bool bi = false)
    {
        assert(from < V), assert(to < V);
        edge[from].push_back(Edge{to, cost}), rev_edge[to].push_back(Edge(from, cost));
        if (bi) { addEdge(to, from, cost, false); }
    }
    struct Edge
    {
        Edge(const std::size_t to, const T cost) : to{to}, cost{cost} {}
        const std::size_t to;
        const T cost;
        bool operator<(const Edge& e) const { return cost != e.cost ? cost < e.cost : to < e.to; }
    };
    const std::vector<Edge>& operator[](const std::size_t i) const { return assert(i < V), edge[i]; }
    friend std::ostream& operator<<(std::ostream& os, const CostGraph& g)
    {
        os << "[\n";
        for (std::size_t i = 0; i < g.V; i++) {
            for (const auto& e : g.edge[i]) { os << i << "->" << e.to << ":" << e.cost << "\n"; }
        }
        return (os << "]\n");
    }
    const std::size_t V;
    std::vector<std::vector<Edge>> edge, rev_edge;
};
//!=============================================================!//
//!  dP     dP                                              oo  !//
//!  88     88                                                  !//
//!  88    .8P .d8888b. 88d888b. .d8888b. 88d888b. .d8888b. dP  !//
//!  88    d8' 88'  '88 88'  '88 88'  '88 88'  '88 88'  '88 88  !//
//!  88  .d8P  88.  .88 88       88.  .88 88    88 88.  .88 88  !//
//!  888888'   '88888P' dP       '88888P' dP    dP '88888P' dP  !//
//!=============================================================!//
template <typename T>
CostGraph<T> Voronoi(const CostGraph<T>& G, const std::vector<std::size_t>& S)
{
    using P = std::pair<std::size_t, std::size_t>;
    using PP = std::pair<T, P>;
    constexpr T INF = std::numeric_limits<T>::max();
    const std::size_t V = G.V, N = S.size();
    std::vector<T> D(V, INF);
    std::vector<std::size_t> from(V, V);
    std::priority_queue<PP, std::vector<PP>, std::greater<PP>> Q;
    for (std::size_t i = 0; i < N; i++) { Q.push({T{}, {S[i], S[i]}}); }
    CostGraph<T> ans(V);
    while (not Q.empty()) {
        const auto p = Q.top();
        Q.pop();
        const T d = p.first;
        const std::size_t s = p.second.first, f = p.second.second;
        if (D[s] <= d) { continue; }
        D[s] = d, from[s] = f;
        for (const auto& e : G[s]) {
            const std::size_t to = e.to;
            const T cost = e.cost;
            if (D[to] == INF) {
                Q.push({d + cost, {to, from[s]}});
            } else {
                if (from[s] != from[to]) { ans.addEdge(from[to], from[s], D[to] + D[s] + cost, true); }
            }
        }
    }
    return ans;
}
// https://atcoder.jp/contests/keyence2019/tasks/keyence2019_e
using ll = long long;
int main()
{
    std::size_t N;
    ll D;
    std::cin >> N >> D;
    std::vector<ll> A(N);
    for (std::size_t i = 0; i < N; i++) { std::cin >> A[i]; }
    CostGraph<ll> G(2 * N);
    for (std::size_t i = 0; i < N; i++) { G.addEdge(i, i + N, A[i], true); }
    for (std::size_t i = 0; i < N - 1; i++) { G.addEdge(i, i + 1, D, true); }
    std::vector<std::size_t> S(N);
    std::iota(S.begin(), S.end(), N);
    const auto T = Voronoi(G, S);
    ll ans = 0;
    for (std::size_t i = N; i < 2 * N; i++) {
        for (const auto& e : T[i]) { ans += e.cost; }
    }
    std::cout << ans / 2 << std::endl;
    return 0;
}


Measured memory_bytes: 120684