Hide

Problem H
Mult!

Nora Mainder has a game she plays with her students to help them learn multiplication. She calls out a sequence of numbers and the students have to determine when she names a whole number multiple of the first number. When a student recognizes such a multiple, he or she must call out “Mult!”, ending this round of the game. Then a new round begins with a new initial number. Fortunately her students are very bright and never fail to recognize a multiple, so they all cry out at once—a “multitude” of shouts.

For instance, if she calls out “$8$, $3$, $12$, $6$, $24$,” her students all yell “Mult!” when she reaches $24$ because it is a multiple of the first number, $8$. If she begins a second round of the game with the sequence “$14$, $12$, $9$, $70$,” the class will call out “Mult!” when she reaches $70$, a multiple of the first number, $14$.

Given a sequence of numbers called out by Nora during several rounds of the game, identify which numbers ought to produce a shout of “Mult!”

Input

The first line of input contains an integer $n$, $2 \leq n \leq 1\, 000$, the length of the number sequence. The following $n$ lines contains the sequence, one number per line. All numbers in the sequence are positive integers less than or equal to $100$. The sequence is guaranteed to contain at least one complete round of the game (but may end with an incomplete round).

Output

Print all of the sequence elements that will cause the class to shout “Mult!” Each value should be printed on a separate line.

Sample Input 1 Sample Output 1
10
8
3
12
6
24
14
12
9
70
5
24
70
Sample Input 2 Sample Output 2
5
3
3
2
5
7
3
CPU Time limit 1 second
Memory limit 1024 MB
Author
Bob Roos
Source 2021 ICPC North American Qualifier Contest (Jan 2022)
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in