CPython lite logoProblemsContests

43. Linear Search #2

 Given n numbers. Write a program that finds the index of the 2nd occurrence of the number 1 among these numbers. Indexing starts from 0.


Input

The first line contains a natural number, n(1n1000).

The second line contains n numbers separated by spaces, ai(1ai1000).

Output

Output the solution in a single line. If the index does not exist, output -1.


Sample input 1

3
2 1 1

Sample output 1

2

Sample input 2

3
4 3 1

Sample output 2

-1

Login to be able to submit.

BasicData structuresLoops
239 / 20
Solved / unsolved count
1.0 s / 512 MB
Limits