License to Launch

Interview

Time limit1sMemory limit512 MB

Summary
Find the earliest index of the minimum value in an array of n space-junk counts and print the zero-based day.
Level

Easy2 of 10

Topics
Array, Implementation, Brute force
Solved
No attempts yet

Problem

Birk has built a new rocket and just received a license from the Bluesky Global Order (BGO) to launch on any day within the next nn days. He worries that the rocket might hit space junk on the way up, so he has modeled how many pieces of space junk will be present on each of the next nn days. He will launch on the day with the least space junk, and if several days have the same amount, he wants to launch as early as possible.

Help Birk determine how many days he must wait before launching.

Input

The first line contains a single integer nn (1≤n≤100 0001 \le n \le 100\,000), the number of days the launch license is valid.

The second line contains nn integers between 00 and 10910^9. The ii-th integer is the amount of space junk on the ii-th day. The first day is day i=0i = 0.

Output

Output a single integer: the number of days Birk must wait before he launches his rocket.

Examples1

  1. Example 1

    Input
    5
    3 4 1 7 2
    
    Expected output
    2