#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
long long n,d,a[200005],r[200005],l[200005];
int main()
{
	cin>>n>>d;
	long long ret=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ret+=a[i];
	}    
	ret+=(n-1)*d;
	//cout<<ret<<endl;
	r[0]=a[0];
	for(int i=1;i<n;i++)
	    r[i]=min(a[i],r[i-1]+d);
	l[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
	    l[i]=min(a[i],l[i+1]+d);
	for(int i=1;i<n-1;i++)
	    ret+=min(l[i],r[i]);
	cout<<ret;
	return 0;
}
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

int main()
{
    int n;
    ll d;
    cin >> n >> d;
    ll a[200005];
    priority_queue<P, vector<P>, greater<P>> que;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        que.push(P(a[i], i));
    }
    bool used[200005]{0};
    ll ans = 0;
    while(que.size()){
        P p = que.top();
        que.pop();
        int u = p.second;
        if(u > 0 && !used[u]){
            ans += d + a[u] + a[u - 1];
            if(d + a[u] < a[u - 1]){
                a[u - 1] = d + a[u];
                que.push(P(a[u - 1], u - 1));
            }
            used[u] = true;
        }
        if(u < n - 1 && !used[u + 1]){
            ans += d + a[u] + a[u + 1];
            if(d + a[u] < a[u + 1]){
                a[u + 1] = d + a[u];
                que.push(P(a[u + 1], u + 1));
            }
            used[u + 1] = true;
        }
    }
    cout << ans << endl;
}
