Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

This round has an unusual addition to the rules. For each problem you must use distinct language. Thus, if you have a submission that has passed at least one test or is being tested at the moment, then for this task you can use only this language and can not use it for other tasks. More details can be read by the link. Different implementations of the same language are considered to be the same language (for example, in C++ you can only solve one problem, regardless of the exact chosen compiler).

No tag edit access

F. Pens And Days Of Week

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputStepan has *n* pens. Every day he uses them, and on the *i*-th day he uses the pen number *i*. On the (*n* + 1)-th day again he uses the pen number 1, on the (*n* + 2)-th — he uses the pen number 2 and so on.

On every working day (from Monday to Saturday, inclusive) Stepan spends exactly 1 milliliter of ink of the pen he uses that day. On Sunday Stepan has a day of rest, he does not stend the ink of the pen he uses that day.

Stepan knows the current volume of ink in each of his pens. Now it's the Monday morning and Stepan is going to use the pen number 1 today. Your task is to determine which pen will run out of ink before all the rest (that is, there will be no ink left in it), if Stepan will use the pens according to the conditions described above.

Input

The first line contains the integer *n* (1 ≤ *n* ≤ 50 000) — the number of pens Stepan has.

The second line contains the sequence of integers *a*_{1}, *a*_{2}, ..., *a*_{n} (1 ≤ *a*_{i} ≤ 10^{9}), where *a*_{i} is equal to the number of milliliters of ink which the pen number *i* currently has.

Output

Print the index of the pen which will run out of ink before all (it means that there will be no ink left in it), if Stepan will use pens according to the conditions described above.

Pens are numbered in the order they are given in input data. The numeration begins from one.

Note that the answer is always unambiguous, since several pens can not end at the same time.

Examples

Input

3

3 3 3

Output

2

Input

5

5 4 5 4 4

Output

5

Note

In the first test Stepan uses ink of pens as follows:

- on the day number 1 (Monday) Stepan will use the pen number 1, after that there will be 2 milliliters of ink in it;
- on the day number 2 (Tuesday) Stepan will use the pen number 2, after that there will be 2 milliliters of ink in it;
- on the day number 3 (Wednesday) Stepan will use the pen number 3, after that there will be 2 milliliters of ink in it;
- on the day number 4 (Thursday) Stepan will use the pen number 1, after that there will be 1 milliliters of ink in it;
- on the day number 5 (Friday) Stepan will use the pen number 2, after that there will be 1 milliliters of ink in it;
- on the day number 6 (Saturday) Stepan will use the pen number 3, after that there will be 1 milliliters of ink in it;
- on the day number 7 (Sunday) Stepan will use the pen number 1, but it is a day of rest so he will not waste ink of this pen in it;
- on the day number 8 (Monday) Stepan will use the pen number 2, after that this pen will run out of ink.

So, the first pen which will not have ink is the pen number 2.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/13/2018 19:53:42 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|