Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Two's Company, Three's a Crowd

By RHaque · Limits 1s, 512 MB

nn racers have competed in a Formula 1 racing tournament. Given the amount of time taken by each driver to complete the race, write a program that identifies the number of the racer who won the bronze medal (i.e. stood third in the race). Assume, the racers are numbered from 1 to n.


Just in case you don’t know how races work, the racer that takes the least amount of time to finish gets the gold medal, the racer that finished second takes the silver medal, and the racer that took the third-lowest time to finish wins the third prize.

Input

The input contains two lines, the first of which contains nn, the number of competing racers. The second line contains nn space-separated integer values, the ithi^{th} of which denotes aia_{i}, the number of seconds taken by the racer numbered ii to complete the race. You can assume that there were no ties, that is, each racer took a different amount of time to finish.

Constraints:
3n10003 \leq n \leq 1000

1ai1091 \leq a_{i} \leq 10^{9}

Output

Output a single integer, the number of the racer who won the bronze medal.

Sample

InputOutput
4
1 5 4 3
3

Here, racer 1 takes 1 second to finish the race, racer 2 takes 5 seconds and the racers numbered 3 and 4 take 4 and 3 seconds respectively.

Thus, racer 1 wins the first prize, racer 4 wins silver and racer 3 wins the third prize. Therefore, the output is 3.


Image Source: imgflip

Discussion

Statistics


78% Solution Ratio

TanbeerEarliest, 2w ago

ShajibewucseFastest, 0.0s

TanbeerLightest, 131 kB

bokaifShortest, 71B

Submit

Login to submit