Codeforces Round 492 (Div. 2) [Thanks, uDebug!]
B
World Cup
Codeforces
1300
原题
← AC →
翻译中…

Allen wants to enter a fan zone that occupies a round square and has $n$ entrances.

翻译中…

There already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.

翻译中…

Allen uses the following strategy to enter the fan zone:

翻译中…
  • Initially he stands in the end of the queue in front of the first entrance.
  • Each minute, if he is not allowed into the fan zone during the minute (meaning he is not the first in the queue), he leaves the current queue and stands in the end of the queue of the next entrance (or the first entrance if he leaves the last entrance).
翻译中…

Determine the entrance through which Allen will finally enter the fan zone.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($2 \le n \le 10^5$) — the number of entrances.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 10^9$) — the number of people in queues. These numbers do not include Allen.

翻译中…

Output

翻译中…

Print a single integer — the number of entrance that Allen will use.

翻译中…

Note

翻译中…

In the first example the number of people (not including Allen) changes as follows: $[\textbf{2}, 3, 2, 0] \to [1, \textbf{2}, 1, 0] \to [0, 1, \textbf{0}, 0]$. The number in bold is the queue Alles stands in. We see that he will enter the fan zone through the third entrance.

翻译中…

In the second example the number of people (not including Allen) changes as follows: $[\textbf{10}, 10] \to [9, \textbf{9}] \to [\textbf{8}, 8] \to [7, \textbf{7}] \to [\textbf{6}, 6] \to \\ [5, \textbf{5}] \to [\textbf{4}, 4] \to [3, \textbf{3}] \to [\textbf{2}, 2] \to [1, \textbf{1}] \to [\textbf{0}, 0]$.

翻译中…

In the third example the number of people (not including Allen) changes as follows: $[\textbf{5}, 2, 6, 5, 7, 4] \to [4, \textbf{1}, 5, 4, 6, 3] \to [3, 0, \textbf{4}, 3, 5, 2] \to \\ [2, 0, 3, \textbf{2}, 4, 1] \to [1, 0, 2, 1, \textbf{3}, 0] \to [0, 0, 1, 0, 2, \textbf{0}]$.

翻译中…

样例

Input #1
4
2 3 2 0
Output #1
3
InputCopy OutputCopy
Input #2
2
10 10
Output #2
1
InputCopy OutputCopy
Input #3
6
5 2 6 5 7 4
Output #3
6
InputCopy OutputCopy
题目信息
题号
996B
时间限制
1 s
内存限制
256 MB
标签
二分
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。