#include <bits/stdc++.h>
using namespace std;
long long inf = 1e16;
vector<long long> tree;
long long N = 1;
void upd(long long v) {
  if (v == 0) return;
  tree[v] = min(tree[v * 2], tree[v * 2 + 1]);
  upd(v / 2);
}
long long get(long long v, long long l, long long r, long long vl,
              long long vr) {
  if (vr <= l || r <= vl) return inf;
  if (vl <= l && r <= vr) {
    return tree[v];
  }
  long long m = (l + r) / 2;
  return min(get(v * 2, l, m, vl, vr), get(v * 2 + 1, m, r, vl, vr));
}
signed main() {
  long long n, k, e;
  cin >> n >> e >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  while (N < (n + 2)) N *= 2;
  tree = vector<long long>(2 * N, inf);
  vector<long long> suf(n + 1, inf);
  suf[n - 1] = k;
  long long uk = n - 2;
  tree[N + (n - 2)] = k + a[n - 1] + suf[n - 1];
  upd((N + (n - 2)) / 2);
  for (long long i = n - 2; i >= 0; i--) {
    while (uk > 0 && 2 * (a[uk] - a[i]) >= k) {
      tree[N + uk] = 2 * a[uk] + a[uk + 1] + suf[uk + 1];
      upd((N + (uk - 1)) / 2);
      uk--;
    }
    long long ans = max(k, 2 * (a[n - 1] - a[i])) + (a[n - 1] - a[i]);
    long long l = i, r = n + 1;
    while (r - l > 1) {
      long long m = (l + r) / 2;
      if (2 * (a[m] - a[i]) < k)
        l = m;
      else
        r = m;
    }
    ans = min(ans, get(1, 0, N, i, l + 1) - a[i]);
    if (r <= n - 2) {
      ans = min(ans, get(1, 0, N, l + 1, r + 1) - 3 * a[i]);
    }
    suf[i] = ans;
    if (i != 0) {
      tree[N + (i - 1)] = k + a[i] + suf[i];
      upd((N + (i - 1)) / 2);
    }
  }
  cout << a[0] + suf[0] + (e - a[n - 1]) << endl;
  return 0;
}
