Problem: Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.

<image>

A sequence of positive integers bi is harmony if and only if for every two elements of the sequence their greatest common divisor equals 1. According to an ancient book, the key of the chest is a harmony sequence bi which minimizes the following expression:

<image>

You are given sequence ai, help Princess Twilight to find the key.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of elements of the sequences a and b. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 30).

Output

Output the key — sequence bi that minimizes the sum described above. If there are multiple optimal sequences, you can output any of them.

Examples

Input

5
1 1 1 1 1


Output

1 1 1 1 1 

Input

5
1 6 4 2 8


Output

1 5 3 1 8 

Solution (in JAVA):

Solution:
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF453B extends PrintWriter {
	CF453B() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF453B o = new CF453B(); o.main(); o.flush();
	}

	static final int INF = 2901;
	void main() {
		int[] pp = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 };
		int[] bb = new int[59];
		for (int a = 2; a < 59; a++)
			for (int h = 0; h < 16; h++)
				if (a % pp[h] == 0)
					bb[a] |= 1 << h;
		int n = sc.nextInt();
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		int[][] dp = new int[n + 1][1 << 16];
		int[][] cc = new int[n + 1][1 << 16];
		for (int i = 0; i <= n; i++)
			for (int b = 0; b < 1 << 16; b++)
				dp[i][b] = INF;
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			int a = Math.max(aa[i] * 2 - 2, 1);
			for (int b = 0; b < 1 << 16; b++) {
				int x = dp[i][b];
				if (x == INF)
					continue;
				for (int c = 1; c <= a; c++)
					if ((bb[c] & b) == 0) {
						int b_ = bb[c] | b;
						int x_ = x + Math.abs(c - aa[i]);
						if (dp[i + 1][b_] > x_) {
							dp[i + 1][b_] = x_;
							cc[i + 1][b_] = c;
						}
					}
			}
		}
		int b_ = 0;
		for (int b = 1; b < 1 << 16; b++)
			if (dp[n][b_] > dp[n][b])
				b_ = b;
		int[] qq = new int[n]; int cnt = 0;
		for (int i = n; i > 0; i--) {
			int c = cc[i][b_];
			qq[cnt++] = c;
			b_ ^= bb[c];
		}
		while (cnt-- > 0)
			print(qq[cnt] + " ");
		println();
	}
}