// Original C++ solution (slower):
// =================================

//   author: memset0

//   date: 2019.03.20 22:54:35

//   website: https://memset0.cn/

// =================================

#include <bits/stdc++.h>

#define ll long long

#define int long long

#define debug(...) ((void)0)

#ifndef debug

#define debug(...) fprintf(stderr,__VA_ARGS__)

#endif

namespace ringo {

template <class T> inline void read(T &x) {

	x = 0; register char c = getchar(); register bool f = 0;

	while (!isdigit(c)) f ^= c == '-', c = getchar();

	while (isdigit(c)) x = x * 10 + c - '0', c = getchar();

	if (f) x = -x;

}

template <class T> inline void print(T x) {

	if (x < 0) putchar('-'), x = -x;

	if (x > 9) print(x / 10);

	putchar('0' + x % 10);

}

template <class T> inline void print(T x, char c) { print(x), putchar(c); }



const int N = 1e5 + 10;

int n, m, k, ans, a[N], f[N];



struct seg {

	int min[N << 2];

	void modify(int u, int k, int v, int l = 0, int r = n) {

		// printf("modify %d %d %d %d %d\n", u, k, v, l, r);

		if (l == r) { min[u] = v; return; }

		int mid = (l + r) >> 1;

		if (k <= mid) modify(u << 1, k, v, l, mid);

		else modify(u << 1 | 1, k, v, mid + 1, r);

		min[u] = std::min(min[u << 1], min[u << 1 | 1]);

	}

	int query(int u, int ql, int qr, int l = 0, int r = n) {

		// printf("query %d %d %d %d %d : %d\n", u, ql, qr, l, r, min[u]);

		if (ql > qr) return f[N - 1];

		if (ql == l && qr == r) return min[u];

		int mid = (l + r) >> 1;

		if (qr <= mid) return query(u << 1, ql, qr, l, mid);

		if (ql > mid) return query(u << 1 | 1, ql, qr, mid + 1, r);

		return std::min(query(u << 1, ql, mid, l, mid), query(u << 1 | 1, mid + 1, qr, mid + 1, r));

	}

} s[2];



void main() {

	memset(f, 0x3f, sizeof(f));

	memset(s[0].min, 0x3f, sizeof(s[0].min));

	memset(s[1].min, 0x3f, sizeof(s[1].min));

	read(n), read(m), read(k);

	for (int i = 1; i <= n; i++) read(a[i]);

	f[0] = 0;

	s[0].modify(1, 0, -2 * a[1]);

	s[1].modify(1, 0, 0);

	for (int i = 1, from; i <= n; i++) {

		int j = std::lower_bound(a, a + i, (a[i] * 2 - k + 1) >> 1) - a - 1;

		f[i] = std::min(f[i], 3 * a[i] + s[0].query(1, std::max((int)0, (int)0), std::min(n, j - 1)));

		f[i] = std::min(f[i], a[i] + k + s[1].query(1, std::max((int)0, (int)j), std::min(n, i - 1)));

		s[0].modify(1, i, f[i] - a[i] - 2 * a[i + 1]);

		s[1].modify(1, i, f[i] - a[i]);

		// printf("[%d %d] %d %d | [%d %d] %d %d\n",

		// 	0, j - 1, 3 * a[i], s[0].query(1, 0, j - 1),

		// 	j, i - 1, a[i] + k, s[1].query(1, j, i - 1));

	}

	ans = f[n] + m - a[n];

	print(ans, '\n');

}



} signed main() { return ringo::main(), 0; }

// Optimized solution to the same problem (faster):
/*

Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£

¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£

±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£

Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£

D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£

´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£

±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£

Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£

µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£

Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£

*/

#include <bits/stdc++.h>

using namespace std;

#define fi			first

#define se			second

#define fz(i,a,b)	for(int i=a;i<=b;i++)

#define fd(i,a,b)	for(int i=a;i>=b;i--)

#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)

#define put(x)		putchar(x)

#define eoln        put('\n')

#define space		put(' ')

#define int long long

inline int read(){

	int x=0,neg=1;char c=getchar();

	while(!isdigit(c)){

		if(c=='-')	neg=-1;

		c=getchar();

	}

	while(isdigit(c))	x=x*10+c-'0',c=getchar();

	return x*neg;

}

inline void print(int x){

	if(x<0){

		putchar('-');

		print(abs(x));

		return;

	}

	if(x<=9)	putchar(x+'0');

	else{

		print(x/10);

		putchar(x%10+'0');

	}

}

int n=read(),E=read(),T=read(),a[100005];

int dp[100005];//dp[i]=min(dp[j]+a[i]-a[j]+max(T,2*(a[i]-a[j+1]))=;

signed main(){

	fz(i,1,n)	a[i]=read();

	memset(dp,63,sizeof(dp));

	deque<int> q;

	q.push_back(0);

	dp[0]=0;

	int mn=0x3f3f3f3f3f3f3f3fll;

	fz(i,1,n){

		while(!q.empty()&&2*(a[i]-a[q.front()+1])>T){

			int j=q.front();

			mn=min(mn,dp[j]-a[j]+2*(-a[j+1]));

			q.pop_front();

		}

		dp[i]=min(dp[i],dp[q.front()]+a[i]-a[q.front()]+T);

		dp[i]=min(dp[i],mn+3*a[i]);

		while(!q.empty()&&dp[q.back()]-a[q.back()]>dp[i]-a[i])	q.pop_back();

		q.push_back(i);

	}

	cout<<dp[n]+abs(a[n]-E)<<endl;

	return 0;

}

// Fastest known solution for this problem: