

Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 点
問題文
「硬度フェスティバル」は毎年開催される、世界で一番硬い石を決める大会です。
今年の硬度フェスティバルには 個の石が参加します。 番目の石の硬度は です。
大会では石をトーナメント形式でぶつけ合って、最硬の石を決めます。
硬度 の石と硬度 の石をぶつけると以下のような結果になります。
-
> のとき: 硬度が だった石は砕けて、 硬度が だった石の硬度は になります。 このとき硬度が だった石が勝ち残ります。
-
= のとき: どちらかの石が砕けます。もう片方の石が硬度が元と変わらないまま残ります。このとき砕けなかった方の石が勝ち残ります。
-
< のとき: 硬度が だった石は砕けて、 硬度が だった石の硬度は になります。 このとき硬度が だった石が勝ち残ります。
個の石は以下のようなトーナメント形式で勝負をします。
-
( 番目の石、 番目の石)、( 番目の石、 番目の石)、... の組み合わせでぶつけ合う。
-
( の勝ち残り、 の勝ち残り)、( の勝ち残り、 の勝ち残り)、... の組み合わせでぶつけ合う。
-
同様に、勝ち残りが つだけになるまで続ける。
最後まで勝ち残る石の、最後の時点での硬度を求めてください。
制約
- は整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
最後まで勝ち残る石の、最後の時点での硬度を出力せよ。
入力例 1Copy
2 1 3 10 19
出力例 1Copy
7
入力例 2Copy
3 1 3 2 4 6 8 100 104
出力例 2Copy
2
Score : points
Problem Statement
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, stones participated. The hardness of the -th stone is .
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness and are thrown at each other, the following will happen:
-
When > : The stone with hardness will be destroyed and eliminated. The hardness of the stone with hardness will become .
-
When = : One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
-
When < : The stone with hardness will be destroyed and eliminated. The hardness of the stone with hardness will become .
The stones will fight in a knockout tournament as follows:
-
The following pairs will fight: (the -st stone versus the -nd stone), (the -rd stone versus the -th stone), ...
-
The following pairs will fight: (the winner of (-st versus -nd) versus the winner of (-rd versus -th)), (the winner of (-th versus -th) versus the winner of (-th versus -th)), ...
-
And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
- is an integer.
Input
The input is given from Standard Input in the following format:
:
Output
Print the eventual hardness of the last stone remaining.
Sample Input 1Copy
2 1 3 10 19
Sample Output 1Copy
7
Sample Input 2Copy
3 1 3 2 4 6 8 100 104
Sample Output 2Copy
2