#P6332. [COCI 2007/2008 #1] PRINOVA

[COCI 2007/2008 #1] PRINOVA

Problem Description

Given an even sequence p1,,pnp_1,\dots,p_n of length nn and two integers A,BA, B, find an odd number X[A,B]X \in [A, B] such that min{Xpi}\min{\{|X - p_i|}\} is maximized.

Input Format

The first line contains an integer nn, indicating the length of the sequence.

The second line contains nn numbers p1,,pnp_1,\dots,p_n, describing this even sequence.

The third line contains two integers A,BA, B, with the meaning as described in the problem statement.

Output Format

Output one integer in one line, representing your answer.

If there are multiple answers, you may print any one of them. This problem uses SPJ.

3
2 6 16
20 50
49
3
2 6 16
3 15
11
3
2 6 16
1 7
5

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n1001 \le n \le 100, 2pi1092 \le p_i \le 10^9, and 1A,B1091 \le A, B \le 10^9.

Notes

Translated from COCI2007-2008 CONTEST #1 T3 PRINOVA.

Translated by ChatGPT 5