Mirko is a party animal, so he has decided to organise an endless amount of parties for his friends. To satisfy the party's needs, he has decided to set up
tables with candy on them. We know the number of candies
on each table. On the first day of the rest of eternity, Mirko is going to invite one friend per table, on the second day he will invite two friends per table, on the third day three friends... In general, obviously, on the
day he is going to invite
friends per each table.
When his friends enter the room,
people will sit down at each table and they will divide the candies on their table into
as large as possible equal pieces, and get rid of the possible remains. After the candy division, because of jealousy and various other reasons, only tables with the same amount of candy per capita will socialise together. Mirko has all eternity to study the social dynamics of his parties. Firstly, he wants to know the answer to the following question: given an
between
and
, what is the earliest day when there is a group of exactly
tables socialising together?
As usual, Mirko is incapable of solving his own problems, so every few days he comes to you and asks you what the required number is, given an
. Alas, he has all eternity to ask questions, but you don't. Therefore, you are going to write a programme which outputs Mirko's required answers for each
from
to
.
Please note: Before each party, Mirko renews the candy supply on each table, meaning the supplies are equal to those before the first party. Additionally, all people leave the current party before the next one starts.
Input Specification
The first line of input contains the integer
.
The second line of input contains
integers, the
number marking the number of candy on the
table.
The numbers are from the interval
.
Output Specification
Output
lines, each line containing a single integer.
The
line should contain the required number for a group sized
or -1
if there will never be a group of that size.
Scoring
In test cases worth
of total points, the number of candy on all tables will not exceed
.
In test cases worth additional
of total points, the number of candy on all tables will not exceed
.
Sample Input 1
Copy
5
11 10 9 6 4
Sample Output 1
Copy
1
2
3
6
12
Explanation for Sample Output 1
On the first day, each table will socialise only with itself so the answer for groups sized
is
. Already on the second day, people sitting at tables
and
are going to get
candies per capita and socialise together, so the answer for a group sized
is
.
On the third day, tables
,
and
will socialise (because they all have
candies per capita).
On the sixth day, tables
,
,
and
will socialise (because they now have
candy per capita).
Finally, on the twelfth day, all tables will socialise together because they will all get zero candy per capita.
Sample Input 2
Copy
3
5 5 5
Sample Output 2
Copy
-1
-1
1
Explanation for Sample Output 2
All tables have the same amount of candy per capita, so a group sized less than
will never exist.
Sample Input 3
Copy
8
12 16 95 96 138 56 205 84
Sample Output 3
Copy
1
5
14
49
96
97
139
206
Comments