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

#SP0000235. Chiếc rương hòa hợp của Little Pony (Little Pony and Harmony Chest)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Chiếc rương hòa hợp của Little Pony (Little Pony and Harmony Chest)

Little Pony and Harmony Chest

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Princess Twilight finds a harmony chest. Its key is a sequence of positive integers b1,b2,…,bnb_1,b_2,\ldots,b_n in which every two entries at different positions are coprime:

$$\gcd(b_i,b_j)=1\quad \text{for all }1\le i<j\le n.$$

Given positive integers a1,a2,…,ana_1,a_2,\ldots,a_n, construct a valid sequence bb minimizing the sum of absolute deviations

∑i=1n∣ai−bi∣.\sum_{i=1}^{n}|a_i-b_i|.

If multiple optimal sequences exist, you may output any of them.

Input

Line 1 contains nn. Line 2 contains exactly nn integers a1,a2,…,ana_1,a_2,\ldots,a_n.

Output

Print exactly nn positive integers b1,b2,…,bnb_1,b_2,\ldots,b_n, in order, forming a pairwise coprime sequence with minimum ∑∣ai−bi∣\sum |a_i-b_i|.

Subtasks

  • Subtask 1 (20 points): 1≤n≤61\le n\le6; 1≤ai≤81\le a_i\le8 for all ii.

  • Subtask 2 (30 points): 1≤n≤301\le n\le30; 1≤ai≤201\le a_i\le20 for all ii.

  • Subtask 3 (50 points): 1≤n≤1001\le n\le100; 1≤ai≤301\le a_i\le30 for all ii.

Examples

Input

5
1 1 1 1 1

Output

1 1 1 1 1

Explanation

The input contains five 11s. Choose b=[1,1,1,1,1]b=[1,1,1,1,1]. Every pair has gcd⁡(1,1)=1\gcd(1,1)=1, so the sequence is valid. Each deviation ∣1−1∣=0|1-1|=0, yielding total cost 00. Since absolute values are nonnegative, no smaller cost is possible; this output is optimal.