891. Largest Special Subset

0

Medium

Given a set of positive integers nums, find the largest subset, answer, that satisfies a special property. The special property states that for every pair of elements (result[i], result[j]) in the subset, either result[i] is divisible by result[j] or result[j] is divisible by result[i]. If there are multiple solutions, return the lexicographically smallest subset.

Input Format

The first line of the input should contain an integer n, which represents the size of the nums array. The following n lines should each contain an integer element of the nums array.

Output Format

Print the lexicographically smallest subset, answer, as a space-separated list of integers.

Example

Input

3
1
2
3

Output

1 2

Constraints

Loading...

View Submissions

Console