PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000191. Khôi phục dãy đã trộn (Recover it!)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Khôi phục dãy đã trộn (Recover it!)

Khôi phục dãy đã trộn (Recover it!)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A hidden array aa has nn integers greater than 11. For each original xx, append one new integer: if xx is prime, append the xx-th prime number in the ordered sequence 2,3,5,7,…2,3,5,7,\ldots; otherwise append the largest proper positive divisor of xx. Shuffle all 2n2n resulting values into array bb. Recover any valid original array aa. A solution is guaranteed to exist; the order of your output array is arbitrary.

Input

First line: nn. Second line: exactly 2n2n integers of array bb.

Output

Print exactly nn integers aia_i that could produce the given multiset bb. Any valid answer is accepted.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; 2≤ai≤10002\le a_i\le 1000; 2≤bi≤27501312\le b_i\le 2750131.

  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; 2≤ai≤200002\le a_i\le 20000; 2≤bi≤27501312\le b_i\le 2750131.

  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 2≤ai≤2000002\le a_i\le 200000; 2≤bi≤27501312\le b_i\le 2750131.

Examples

Example 1

Input

3
3 5 2 3 2 4

Output

3 4 2

Explanation

The original array [3,4,2][3,4,2] appends respectively the third prime 55, the greatest proper divisor 22 of 44, and the second prime 33. The resulting multiset is exactly the input.

Example 2

Input

1
2750131 199999

Output

199999

Explanation

The prime 199999199999 is accompanied by the 199999199999-th prime, which equals 27501312750131.

Example 3

Input

1
3 6

Output

6

Explanation

The greatest proper positive divisor of composite 66 is 33, hence the original array may be [6][6].