Problem:
Score : 500 points

Problem Statement

We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.

Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action:

Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn.

The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand.

X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?

Constraints

All input values are integers.

1 \leq N \leq 2000

1 \leq Z, W, a_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N Z W
a_1 a_2 ... a_N

Output

Print the score.

Sample Input 1

3 100 100
10 1000 100

Sample Output 1

900

If X draws two cards first, Y will draw the last card, and the score will be |1000 - 100| = 900.

Sample Input 2

3 100 1000
10 100 100

Sample Output 2

900

If X draws all the cards first, the score will be |1000 - 100| = 900.

Sample Input 3

5 1 1
1 1 1 1 1

Sample Output 3

0

Sample Input 4

1 1 1
1000000000

Sample Output 4

999999999

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 1024;
int a[1024];
int dp[MAX_N][MAX_N][2];

const int INF = 1001001001;

struct BITMAX {
  int n;
  int vs[2 * MAX_N + 10];
  BITMAX() {
    this->n = 2 * MAX_N + 10;
    clear();
  }
  void clear() {
    REP(i, 2 * MAX_N + 10) vs[i] = -INF;
  }
    /** [idx, ∞] の範囲の最大値を val で更新しようと試みる */
  void update(int idx, int val) {
    idx = MAX_N - idx;
    for (int x = idx + 1; x <= n; x += x & -x) vs[x] = max(vs[x], val);
  }
  /** [idx, ∞] の範囲の最大値を取得 */
  int get(int idx) {
    idx = MAX_N - idx;
    int ma = -INF;
    for (int x = idx + 1; x > 0; x -= x & -x) ma = max(ma, vs[x]);
    return ma;
  }
};

BITMAX max_y[MAX_N];
BITMAX min_x[MAX_N];

int main2() {
  REP(i, MAX_N) max_y[i].clear();
  REP(i, MAX_N) min_x[i].clear();

  int N = nextInt() + 2;
  REP(i, N) a[i] = nextInt();
  // REP(i, N) REP(j, N) REP(t, N) dp[i][j][t] = 0;

  for (int x = 0; x < N - 1; x++) { 
    dp[x][N-1][0] = abs(a[x] - a[N-1]);
    min_x[x].update(N-1, -dp[x][N-1][0]);
  }
  for (int y = 0; y < N - 1; y++) {
    dp[N-1][y][1] = abs(a[y] - a[N-1]);
    max_y[y].update(N-1, dp[N-1][y][1]);
  }
  for (int x = N - 2; x >= 0; x--) {
    for (int y = N - 2; y >= 0; y--) {
      for (int t = 0; t < 2; t++) {
        if (t == 0 && x < y) {
          // int m = -INF;
          // for (int k = y+1; k < N; k++) chmax(m, dp[k][y][1]);
          int m = max_y[y].get(y+1);
          min_x[x].update(y, -m);
          dp[x][y][0] = m;
        }
        if (t == 1 && y < x) {
          // int m = INF;
          // for (int k = x + 1; k < N; k++) chmin(m, dp[x][k][0]);
          int m = -min_x[x].get(x+1);
          max_y[y].update(x, m);
          dp[x][y][1] = m;
        }
      }
    }
  }
  int ans = dp[0][1][0];
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}