P4715 [Deep Base 16. Example 1] Knockout Tournament

Description

There are $2^n$ ($n \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 $n$, meaning there are $2^n$ countries in total. The second line contains $2^n$ integers. The $i$-th integer represents the strength value of country $i$ ($1 \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.

Explanation/Hint

Translated by ChatGPT 5