import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long INF = 1L<<59;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto D = s[1].to!long;
    auto A = readln.split.map!(to!long).array;

    auto dist = new long[](2*N);
    auto color = new int[](2*N);
    auto pq = new BinaryHeap!(Array!(Tuple!(int, int, long)), "a[2] > b[2]");
    foreach (i; 0..N) pq.insert(tuple(i, i, 0L));
    dist[] = 1L << 59;


    while (!pq.empty) {
        auto n = pq.front[0];
        auto c = pq.front[1];
        auto d = pq.front[2];
        pq.removeFront;
        if (dist[n] <= d) continue;
        dist[n] = d;
        color[n] = c;

        if (n < N) {
            int m = n + N;
            long nd = d + A[n];
            if (dist[m] > nd) {
                pq.insert(tuple(m, c, nd));
            }
        } else {
            foreach (k; [-1, 1]) {
                int m = n + k;
                if (m < N || m >= 2*N) continue;
                long nd = d + D;
                if (dist[m] > nd) {
                    pq.insert(tuple(m, c, nd));
                }
            }
        }
    }


    long ans = 0;

    foreach (i; N..2*N) {
        if (color[i] != color[i-N]) {
            ans += abs(color[i] - color[i-N]) * D + A[color[i]] + A[color[i-N]];
        }
        if (i < 2*N-1 && color[i] != color[i+1]) {
            ans += abs(color[i] - color[i+1]) * D + A[color[i]] + A[color[i+1]];
        }
    }

    ans.writeln;
}
