#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N;
    int64_t D;
    cin >> N >> D;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    typedef pair<int64_t, int> P;
    P INFP = {1e18, -1};
    Segtree<P> stL(N, [](auto a, auto b){ return min(a, b); }, INFP);
    Segtree<P> stR(N, [](auto a, auto b){ return min(a, b); }, INFP);
    for(int i=0; i<N; i++){
        stL.update(i, {A[i]-D*i, i});
        stR.update(i, {A[i]+D*i, i});
    }

    vector<vector<int64_t>> edges;
    for(int i=0; i<N; i++){
        if(i > 0){
            int j = stL.between(0, i-1).second;
            int64_t c = abs(i-j)*D + A[i] + A[j];
            edges.push_back({c, i, j});
        }
        if(i < N-1){
            int j = stR.between(i+1, N-1).second;
            int64_t c = abs(i-j)*D + A[i] + A[j];
            edges.push_back({c, i, j});
        }
    }

    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    int64_t ans = 0;
    for(auto& e : edges){
        int64_t c = e[0], i = e[1], j = e[2];
        if(uf.unite(i, j)) ans += c;
    }
    cout << ans << endl;
    return 0;
}