#include <bits/stdc++.h>

using namespace std;

#define int long long

const int inf = 0x3f3f3f3f3f3f3f3f;
const int N = 100000;

int n, m, s;
int a[N + 1];
int dp[N + 1];
int q[N], head, tail;

#undef int
signed main() {
#define int long long
  cin >> n >> m >> s;
  for (int i = 1; i <= n; i++) cin >> a[i];
  q[tail++] = 0;
  int now = -1, mn = inf;
  for (int i = 1; i <= n; i++) {
    while (now + 1 < i && 2 * a[now + 2] < 2 * a[i] - s)
      now++, mn = min(mn, dp[now] - a[now] - 2 * a[now + 1]);
    while (head < tail && q[head] <= now) head++;
    while (head < tail &&
           dp[q[tail - 1]] - a[q[tail - 1]] >= dp[i - 1] - a[i - 1])
      tail--;
    q[tail++] = i - 1;
    dp[i] = min(dp[q[head]] - a[q[head]] + a[i] + s, mn + 3 * a[i]);
  }
  cout << dp[n] + m - a[n] << "\n";
#undef int
  return 0;
}
