#include <bits/stdc++.h>
using namespace std;
long long dp[2005];
long long a[2005], n, E, T;
int main() {
  cin >> n >> E >> T;
  if (n > 2000) return 0;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 0; i < 2005; i++) dp[i] = 1LL << 60;
  dp[0] = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      long long J1 = a[j] - a[i];
      long long J2 = a[j] - a[i + 1];
      long long J3 = 0;
      if (J2 * 2 < T) J3 = T - J2 * 2;
      long long J4 = a[j] - a[i + 1];
      dp[j] = min(dp[j], dp[i] + J1 + J2 + J3 + J4);
    }
  }
  long long minx = 1LL << 60;
  cout << dp[n] + abs(a[n] - E) << endl;
  return 0;
}
