LCC '23 Contest 2 J1 - Portals

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Macduff, a loyal servant of Duncan's, has been tasked to hunt down Macbeth, the suspected killer of Duncan. It certainly didn't help that before leaving, Macbeth ambushed his family and egged them (threw eggs at them).

Filled with hatred and a strong desire for revenge, Macduff has determined that he will hunt Macbeth down and exact his revenge, even if it means he will have to travel to other dimensions and time periods.

That's exactly what Macduff is being confronted with right now. Macbeth has escaped using a portal room that was given to him by people from the future, who seem to be supporting Macbeth.

Macduff is at a loss, since there are N identical portals in the room, and he has no way of finding out which portal Macbeth escaped through.

Upon further inspection, it would appear that each portal is numbered on the back! Macduff guessed that it might have something to do with the order that Macbeth tested each portal in, so it would seem most likely that Macbeth escaped through the portal with the largest number, since it's likely the one that he went through last.

However, Macbeth is not that stupid. He shuffled the portals before leaving, so that the portal's index do not match with their number.

Given these N portals, each with the number N_i, which one should Macduff go through?

Constraints

1 \le N_i \le N \le 10^5.

All values for N_i are distinct.

Input Specification

The first line will contain one integer, N. The next line will contain N integers, N_i.

Output Specification

Output the index of the portal that Macduff should go through.

Sample Input

5
2 5 4 3 1

Sample Output

2

Sample Output Explanation

The second portal has the largest number, so it is most likely that Macduff escaped through the second one.


Comments

There are no comments at the moment.