cswork / OAOpen practice workspace

AmazonOA #246

Inventory Processes Survival Possibility

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyPrefix & Ranges

Each time, choose any two current tasks to fight; the one with more robots wins and absorbs all of the other's robots, and with equal counts either side may win. This continues until only one task remains. Output, in ascending order, every original 1-based index for which at least one process lets that task survive to the end.

Input

The first line contains n; the second line contains the robot counts. 1≤n≤200000, 1≤count≤10^9. Task indices are distinct, while counts may be equal.

Output

Output the 1-based indices of all tasks that can survive, in ascending order, separated by spaces.

Example 1

Input:

5
1 6 2 7 2

Output:

2 4

Example 2

Input:

2
1 1

Output:

1 2

Example 3

Input:

3
1 2 3

Output:

2 3

Example notes

The answers are 2 4, 1 2 and 2 3. In a fight between equal counts, whichever task you pick is allowed to win.

Editorial

Loading solution…