Mock CCC '19 Contest 1 J4 - Factors

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Bruce is given a multiset a of N integers. Bruce defines f(x) to be the set of factors of x, including 1 and x. Bruce would like to know f(a_1) \cap f(a_2) \cap \ldots \cap f(a_N). That is, Bruce would like to know the common factors that exists in all elements in a.

Input Specification

The first line will contain the integer N (1 \le N \le 10^5).

The second line will contain N integers, a_1, a_2, \ldots, a_N (1 \le a_i \le 10^6).

Output Specification

Output the factors that are common to all elements in a, one factor per line, in sorted order.

Subtasks

For 5/15 of the points, N \le 10.

Sample Input

4
28 12 8 20

Sample Output

1
2
4

Comments

There are no comments at the moment.