![](http://img.atcoder.jp/assets/top/img/flag-lang/ja.png)
![](http://img.atcoder.jp/assets/top/img/flag-lang/en.png)
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 1300 点
問題文
N 段のピラミッドがあります。 段は上から順に 1, 2, ..., N と番号が振られています。 各 1≤i≤N について、i 段目には 2i-1 個のブロックが横一列に並んでいます。 また、各段の中央のブロックに注目すると、これらは縦一列に並んでいます。
![](https://atcoder.jp/img/agc006/a2bde72df5ad036d1699f4a74d74a370.png)
N=4 段のピラミッド
すぬけ君は N 段目のブロックに (1, 2, ..., 2N-1) を並べ替えたもの(順列)を書き込みました。 さらに、次のルールに従い、残りすべてのブロックに整数を書き込みました。
- あるブロックに書き込まれる整数は、そのブロックの左下、真下、右下のブロックに書き込まれた整数の中央値である。
![](https://atcoder.jp/img/agc006/a940f1d8303f255e1f91d17a5696633f.png)
ブロックに整数を書き込む例
その後、すぬけ君はすべてのブロックに書き込まれた整数を消してしまいました。 すぬけ君は、N 段目のブロックに書き込まれた順列が (a_1, a_2, ..., a_{2N-1}) であったことだけを覚えています。
1 段目のブロックに書き込まれた整数を求めてください。
制約
- 2≤N≤10^5
- (a_1, a_2, ..., a_{2N-1}) は (1, 2, ..., 2N-1) の順列である。
入力
入力は以下の形式で標準入力から与えられる。
N a_1 a_2 ... a_{2N-1}
出力
1 段目のブロックに書き込まれた整数を出力せよ。
入力例 1
4 1 6 3 7 4 5 2
出力例 1
4
問題文中の図の例です。
入力例 2
2 1 2 3
出力例 2
2
Score : 1300 points
Problem Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.
![](https://atcoder.jp/img/agc006/a2bde72df5ad036d1699f4a74d74a370.png)
A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N. Then, he wrote integers into all remaining blocks, under the following rule:
- The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.
![](https://atcoder.jp/img/agc006/a940f1d8303f255e1f91d17a5696633f.png)
Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only remembers that the permutation written into the blocks of step N was (a_1, a_2, ..., a_{2N-1}).
Find the integer written into the block of step 1.
Constraints
- 2≤N≤10^5
- (a_1, a_2, ..., a_{2N-1}) is a permutation of (1, 2, ..., 2N-1).
Input
The input is given from Standard Input in the following format:
N a_1 a_2 ... a_{2N-1}
Output
Print the integer written into the block of step 1.
Sample Input 1
4 1 6 3 7 4 5 2
Sample Output 1
4
This case corresponds to the figure in the problem statement.
Sample Input 2
2 1 2 3
Sample Output 2
2