The Beatles

4.5

2 votes
Prime Factorization, LCM, Medium-Hard, Mathematics, Factorization
Problem

Fedor plays in a band, consisting of n musicians. They are all fans of The Beatles band. They want to repeat famous photo of musicians made on Abbey Road long time ago. Fedor and his friends found a good place to take photo and lined up along the beginning of a pedestrian crossing. They will start walking simultaneously, making several steps, and i-th person makes a single step in ai seconds.

They agreed, that the photo has to be taken the first time, when they all finish their step simultaneously.

But Fedor likes to be special. He spoke to the photographer and told him to take photo at the first moment, when n1 of the guys finish their steps and one of them doesn't.

Find, which one of the guys doesn't finish his step, when the photo is taken.

Input format

First line contains single integer n — the number of musicians in the band (2n5105).

Second line consists of n integers a1,a2,an — time for a single step of each person (1ai106).

Output format

Output single integer: musician number, who doesn't finish his step, when the photo is taken. If no photo is going to be taken, output -1.

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The first moment when all except one of the musicians finish a step is at time 30. First, third, fourth and fifth musicians finish their step, but second doesn't. Because 30 is divisible by 5, 10, 3 and 15, but is not a multiple of 12.

Editor Image

?