VK Cup 2017 - Wild Card Round 1 |
---|
Finished |
Stepan 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.
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 a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of milliliters of ink which the pen number i currently has.
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.
3
3 3 3
2
5
5 4 5 4 4
5
In the first test Stepan uses ink of pens as follows:
So, the first pen which will not have ink is the pen number 2.
Name |
---|