#P4715. 【深基16.例1】淘汰赛

【深基16.例1】淘汰赛

Description

There are 2n2^n (n7n \le 7) countries participating in the World Cup finals and entering the knockout stage. The strength value of each country is known, and all values are different. When a country with a higher strength value plays against a country with a lower strength value, the stronger one wins. Country 1 plays a match against Country 2, and the winner advances. Country 3 plays against Country 4, and the winner advances... The advanced countries continue the tournament in the same way until the champion is decided. Given the strength values of all countries, which country is the runner-up?

Input Format

The first line contains an integer nn, meaning there are 2n2^n countries in total.

The second line contains 2n2^n integers. The ii-th integer represents the strength value of country ii (1i2n1 \leq i \leq 2^n, and the strength values are within the int range).

The testdata guarantees that there are no draws.

Output Format

Only one integer, representing the number of the runner-up country.

3
4 2 3 1 10 5 9 7

1

Hint

Translated by ChatGPT 5