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 B = N.iota.map!(i => tuple(A[i], i)).array;
    B.sort!"a[1] > b[1]";

    auto st1 = new SegmentTree!(Tuple!(long, int), min, tuple(1L<<59, 1<<29))(N);
    auto st2 = new SegmentTree!(Tuple!(long, int), min, tuple(1L<<59, 1<<29))(N);
    foreach (i; 0..N) st1.assign(i, tuple(A[i]+D*i, i));
    foreach (i; 0..N) st2.assign(i, tuple(A[i]-D*i, i));

    Tuple!(int, int, long)[] E;

    foreach (b; B) {
        int i = b[1];
        if (i > 0) {
            int j = st2.query(0, i-1)[1];
            if (j >= N) continue;
            E ~= tuple(i, j, abs(i - j) * D + A[i] + A[j]);
        }
        if (i < N - 1) {
            int j = st1.query(i+1, N-1)[1];
            if (j >= N) continue;
            E ~= tuple(i, j, abs(i - j) * D + A[i] + A[j]);
        }
    }


    E.sort!"a[2] < b[2]";
    auto uf = new UnionFind(N);
    long ans = 0;

    foreach (e; E) {
        if (uf.find(e[0]) == uf.find(e[1])) continue;
        ans += e[2];
        uf.unite(e[0], e[1]);
    }

    ans.writeln;
}


class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}
