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

public class A {
	static final int INF = (int)1e6;
	static int n, a [], pFac [], memo[][];
	static int dp(int idx, int msk){
		if(idx == n)
			return 0;
		if(memo[idx][msk] != -1)
			return memo[idx][msk];
		int ans = INF;
		for (int i = 1; i < 60; ++i) {
			if((pFac[i] & msk) == 0)
				ans = Math.min(ans, dp(idx+1, msk | pFac[i]) + Math.abs(a[idx] - i));
		}
		return memo[idx][msk] = ans;
	}
	static StringBuilder sb;
	static void print(int idx, int msk){
		if(idx == n)
			return;
		int opt = dp(idx, msk);
		for (int i = 1; i < 60; ++i) {
			if((pFac[i] & msk) == 0 && dp(idx+1, msk | pFac[i]) + Math.abs(a[idx] - i) == opt){
				sb.append(i).append(" ");
				print(idx+1, msk | pFac[i]);
				return;
			}
		}
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		n = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextInt();
		}
		pFac = new int[60];
		boolean [] isComposite = new boolean[60];
		isComposite[0] = isComposite[1] = true;			
		for (int i = 2; i < 60; ++i) 		
			if (!isComposite[i]) 				
			{
				for (int j = i * i; j < 60; j += i)	
					isComposite[j] = true;
			}   
		for (int i = 0; i < pFac.length; ++i) {
			for (int j = 0, k = 0; j < isComposite.length; ++j) {
				if(!isComposite[j]){
					if(i % j == 0)
						pFac[i] |= 1<<k;
					++k;
				}
			}
		}
		memo = new int[n+1][(1<<17)+1];
		for(int []i:memo)
			Arrays.fill(i, -1);
		sb = new StringBuilder();
		print(0, 0);
		out.println(sb);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

	}

}