You are in a labyrinth that is on a straight line.
Apparently, if you will follow orders and listen to the signs, you will find your way out of the labyrinth either on the east (right) or west (left) sides of it, it may also be that you are stuck in there forever.
The labyrinth is represented as a list of numbers containing instructions, a positive number means that you should go that number of steps to the right side, while a negative number means you need to go to the left. If you find yourselves in a cell in which the number 0 is written, you are stuck for good.
You will find yourselves starting at a random call of the labyrinth, and you have no way to know where you will start. You just need to follow the instructions until you are out in the better case, or stuck in the worst case.
You have heard that the west side is better than east (no particular reason, life is peaceful there)
Luckily for you, you get the map of the labyrinth in advance, and you also have the opportunity to change exactly one of the signs so it will show a different number than it was originally.
Since you have no clue where you will start, your mission here is to increase your chances to get out of the left side.
Your program should return as output a single number, which is the number of the cell you need to change in order to increase your chances of getting out from the west side. If there is more than one cell that fit, you must return the left most cell.
The first line of input includes a singe number N - the number of cells in the labyrinth
The second line have N numbers, which are the numbers on the signs you need to follow.
First example explained:
In this example all the cells contain 1, so no matter where you will start you will always get out in the right side. Changing the last cell will allow us to always go west.
The second example has all values at, so in any case there is only one cell which will allow us to leave, so we will pick the first cell, numbered 1.
In the third example, all values are negative, so we don't need to change anything and return 0.
In the forth sample, it is best to change the 4th cell.
You must be