#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+10;
pair<long long int,int>seg[4*maxn];
pair<long long int,int>seg2[4*maxn];
int a[maxn];
long long int dp[2][maxn];
int n;
int e;
int d;
void update(int id,int l,int r,int l2,int r2,long long int val){
if(l>=r2||r<=l2){
	return;
}	
if(l2<=l&&r<=r2&&r-l==1){
		seg[id]={val,l2};
		return ;
}
int mid=(l+r)>>1;
update(id<<1,l,mid,l2,r2,val);
update((id<<1)|1,mid,r,l2,r2,val);
seg[id]=min(seg[id<<1],seg[(id<<1)|1]);
}
pair<long long int,int>get(int id,int l,int r,int l2,int r2){
	if(l>=r2||r<=l2){
		return {(long long int)1e18+10,100000};
	}
	if(l2<=l&&r<=r2){
		return seg[id];
	}
	int mid=(l+r)>>1;
	return min(get(id<<1,l,mid,l2,r2),get((id<<1)|1,mid,r,l2,r2));
}
void update2(int id,int l,int r,int l2,int r2,long long int val){
if(l>=r2||r<=l2){
	return;
}	
if(l2<=l&&r<=r2&&r-l==1){
		seg2[id]={val,l2};
		return ;
}
int mid=(l+r)>>1;
update2(id<<1,l,mid,l2,r2,val);
update2((id<<1)|1,mid,r,l2,r2,val);
seg2[id]=min(seg2[id<<1],seg2[(id<<1)|1]);
}
pair<long long int,int>get2(int id,int l,int r,int l2,int r2){
	if(l>=r2||r<=l2){
		return {(long long int)1e18+10,100000};
	}
	if(l2<=l&&r<=r2){
		return seg2[id];
	}
	int mid=(l+r)>>1;
	return min(get2(id<<1,l,mid,l2,r2),get2((id<<1)|1,mid,r,l2,r2));
}
inline void input();
int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	input();
}
inline void input(){
	cin>>n>>e>>d;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<4*maxn;i++){
		seg[i]={(long long)1e18,(int)1e9};
		seg2[i]={(long long)1e18,(int)1e9};
	}
	for(int i=0;i<n;i++){
		if(i==0){
			dp[0][i]=a[i];
			dp[1][i]=a[i];
			dp[1][i]+=d;
		}
		else{
		int l=0;
		int r=i;
		while(l!=r-1){
			int mid=(l+r)>>1;
			if(2*(a[i]-a[mid])>=d){
				l=mid;
			}
			else{
				r=mid;
			}
		}
		if(2*(a[i]-a[0])<d){
			r=0;
		}
		if(2*(a[i]-a[i-1])>=d){
			l=i-1;
		}
	//	cout<<l<<": "<<r<<" "<<i<<endl;
		pair<long long int,int>p=get(1,0,n,0,l+1);
		//cout<<l<<endl;
		pair<long long int,int>w=get2(1,0,n,r,i);
		dp[0][i]=dp[1][i-1]+(a[i]-a[i-1]);
		dp[1][i]=(long long int)1e18+10;
		if(2*(a[i]-a[0])>=d){
			dp[1][i]=(dp[0][p.second]+1ll*3*(a[i]-a[p.second]));
		}
		if(2*(a[i]-a[i-1])<d){
			dp[1][i]=min(dp[1][i],(long long)(dp[0][w.second]+d+1ll*2*(a[i]-a[w.second])));
		}
		if(dp[1][i-1]+a[i]-a[i-1]+d<=dp[1][i]){
			dp[1][i]=(long long)(dp[1][i-1]+a[i]-a[i-1]+d);
		}
	}
	//	cout<<dp[0][i]<<" "<<dp[1][i]<<endl;
		//cout<<i<<endl;
		update(1,0,n,i,i+1,(long long)(dp[0][i]+1ll*3*(e-a[i])));
		update2(1,0,n,i,i+1,(long long)(dp[0][i]+1ll*2*(e-a[i])));
	}
	cout<<dp[1][n-1]+(e-a[n-1]);
} 