# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, d;
LL a[202020];
vector<pair<int, LL>> g[404040];
int used[404040], dist[404040], col[404040];

vector<pair<LL, pair<int, int>>> gg;

struct UnionFind {
	UnionFind(size_t size) : v(size, -1) {}
	vector<int> v;

    int root(int x) {
        return (v[x] < 0 ? x : v[x] = root(v[x]));
    }

    bool is_root(int x) {
        return x == root(x);
    }

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

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (v[x] > v[y]) swap(x, y);
            v[x] += v[y];
            v[y] = x;
        }
    }

    int size(int x) {
    	return -v[root(x)];
	}
};

int main(){
    INIT;
    cin >> n >> d;
    REP(i, n)cin >> a[i];
    REP(i, n){
        g[i].emplace_back(make_pair(i + n, a[i]));
        g[i + n].emplace_back(make_pair(i, a[i]));
    }
    REP(i, n - 1){
        g[i].emplace_back(make_pair(i + 1, d));
        g[i + 1].emplace_back(make_pair(i, d));
    }
    priority_queue<pair<LL, pair<int, int>>, vector<pair<LL, pair<int, int>>>, greater<pair<LL, pair<int, int>>>> pq;
    int cnt = 1;
    REP(i, n){
        pq.push(make_pair(0, make_pair(i + n, -1)));
    }
    for(int i = n;i < 2*n;i++)col[i] = i - n;

    while((int)pq.size()){
        auto cur = pq.top();
        pq.pop();
        int v = cur.second.first;
        //cout << v << " " << cur.first << endl;
        if(used[v]){
            int pre = cur.second.second;
            if(used[v] > used[pre]){
                //cout << col[v] << " " << col[pre] << endl;
                gg.emplace_back(make_pair(a[col[v]] + a[col[pre]] + d * abs(col[v] - col[pre]), make_pair(col[v], col[pre])));
            }
            continue;
        }
        if(cur.second.second != -1)col[v] = col[cur.second.second];
        used[v] = cnt;
        cnt++;
        dist[v] = cur.first;
        REP(i, (int)g[v].size()){
            LL u = g[v][i].first;
            LL c = g[v][i].second;
            if(u == cur.second.second)continue;
            pq.push(make_pair(dist[v] + c, make_pair(u, v)));
        }
    }
    sort(ALL(gg));
    UnionFind uf(n);
    LL ans = 0;
    REP(i, (int)gg.size()){
        if(uf.same(gg[i].second.first, gg[i].second.second))continue;
        ans += gg[i].first;
        uf.unite(gg[i].second.first, gg[i].second.second);
    }
    cout << ans << endl;
}



Measured memory_bytes: 60008