[CCOIE #-1] 环上游戏

[CCOIE #-1] 环上游戏

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

CCOIE is running on a circular runway with length \(n\text{ m}\) clockwisely. His speed is \(1\text{ m/s}\). There are some gems on the ground, dimming by \(1\) unit per second. Of course, if the gems' brightness here is already zero, there is no need to change. At first, the gem brightness of \(1\text{ m}\) from the starting point (clockwise) is \(g_i\). If the gem is \(0\) where he is, or \(0\) at that instant, he begins to rest.

Question: When he finished, how many meters is he from the starting point (counterclockwise) ?

Tips: The answer is a number in the \(0\sim(n-1)\) range.

Input Description

The first line, a number \(n\) (\(n\leq10^5\)). The second line, \(n\) numbers, the \(i+1^{\text{th}}\) one is \(g_i\) (\(g_i\leq10^9\)).

Output Description

You just need to print out a number to represent the answer.

Sample

Input

4
2 3 2 0

Output

2

Big-Data Example

Click me!

CCOIE #-1

未参加
状态
已结束
规则
OI
题目
1
开始于
2021-02-01 10:00
结束于
2021-02-01 11:30
持续时间
1.5 小时
主持人
参赛人数
1