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:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Abood2B {

	static int N, A[];
	static int memo [][][];
	static int[] pB = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
	static int[] pA = {31, 37, 41, 43, 47, 53, 59};
	static int[] Arr;

	static int solve(int i, int l, int nP) {
		//		System.out.println(i + " " + l + " " + nP);
		if(i == N)
			return 0;

		if(memo[i][l][nP] != -1)
			return memo[i][l][nP];

		int ans = (int) 1e6;
		for (int j = 1; j < 61; j++) {
			boolean pr = false;
			for (int j2 = 0; j2 < pA.length; j2++) {
				if(j == pA[j2])
					pr = true;
			}
			if(pr)
				continue;
			boolean can = true;
			int rem = 0;
			for (int k = 0; k < pB.length; k++) {
				if(j % pB[k] == 0) {
					if((l & (1 << k)) != 0)
						can = false;
					rem |= (1 << k);
				}
			}
			if(can)
				ans = Math.min(ans, Math.abs(j - A[i]) + solve(i + 1, l | rem, nP));
		}

		if(nP < pA.length) 
			ans = Math.min(ans, Math.abs(pA[nP] - A[i]) + solve(i + 1, l, nP + 1));


		return memo[i][l][nP] = ans;
	}

	static void trace(int i, int l, int nP) {
		if(i == N)
			return;


		int opt = solve(i, l, nP);
		for (int j = 1; j < 52; j++) {
			boolean pr = false;
			for (int j2 = 0; j2 < pA.length; j2++) {

				if(j == pA[j2])
					pr = true;
			}
			if(pr)
				continue;
			boolean can = true;
			int rem = 0;
			for (int k = 0; k < pB.length; k++) {
				if(j % pB[k] == 0) {
					if((l & (1 << k)) != 0)
						can = false;
					rem |= (1 << k);
				}
			}

			if(can && opt == Math.abs(j - A[i]) + solve(i + 1, l | rem, nP)) {
				Arr[i] = j;
				trace(i + 1, l | rem, nP);
				return;
			}
		}

		Arr[i] = pA[nP];
		trace(i + 1, l, nP + 1);

	}

	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		N = sc.nextInt();
		A = new int[N];

		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();



		memo = new int[N][1 << pB.length][pA.length + 1];

		for (int i = 0; i < N; i++)
			for (int j = 0; j < (1 << pB.length); j++)
				Arrays.fill(memo[i][j], -1);

		Arr = new int[N];

		trace(0, 0, 0);

		for (int j = 0; j < N; j++)
			out.print(Arr[j] + " ");

		out.println();


		out.flush();
		out.close();
	}

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));}
		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}