Problem J. 10. MIN_MAX
Input file name: standard input
Output file name: standard output
Time limit: 1 s
Memory limit: 1024 MB
You are given a sequence of length n (n is a power of two).
The sequence is divided into two equal-length subsequences, which are again divided into two equal-length subsequences, and so on, until we reach subsequences of length 2.
Each pair of subsequences is grouped using parentheses.
Example: the breakdown of an 8-element sequence a, b, c, d, e, f, g, h:
(a,b,c,d,e,f,g,h)
((a,b,c,d),(e,f,g,h))
(((a,b),(c,d)),((e,f),(g,h)))

Finally, before each opening parenthesis '(', we alternately insert the operations "min", "max", "min", "max", \dots
According to the example above, we obtain the expression:
min(max(min(a,b),max(c,d)),min(max(e,f),min(g,h)))

Help evaluate the result of the final expression.

Input

The first line contains an integer n (2 \le n \le 1024).
It is guaranteed that n is a power of two.
The second line contains a sequence of n integers A_i (1 \le A_i \le 10^6).

Output

Print the result.

Examples

standard inputstandard output
8 1 2 3 4 5 6 7 8 4
4 4 8 9 2 2