atcoder#RELAYC. 硬度フェスティバル
硬度フェスティバル
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.
2
1
3
10
19
7
3
1
3
2
4
6
8
100
104
2