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.util.*;
import java.io.*;

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;
	
	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}
	
	private int nextInt() throws Exception{
		return Integer.parseInt(next());
	}
	
	private long nextLong() throws Exception{
		return Long.parseLong(next());
	}
	
	private double nextDouble() throws Exception{
		return Double.parseDouble(next());
	}
	
	int msk[];
	Map<Integer, Integer> map;
	// int []cnv;
	int [][]dp; 
	byte [][]from;
	final static int MAXN = 60;

	int n;
	int []a;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		n = nextInt();
		a = new int[n];
		for(int i=0;i<n;i++) a[i] = nextInt();

		msk = new int[MAXN];
		map = new HashMap<Integer, Integer>();
		// cnv = new int[51];

		int c = 0;
		for(int i=2;i<=MAXN;i++){
			if (isPrime(i)) {
				// System.out.println(i + " " + c);
				// cnv[c] = i;
				map.put(i, c++);
			}
		}

		for(int i=1;i<MAXN;i++){
			msk[i] = factorize(i);
		}

		dp = new int[n][1<<map.size()+1];
		from = new byte[n][1<<map.size()+1];
		for(int i=0;i<n;i++) {
			Arrays.fill(dp[i], -1);
			// Arrays.fill(from[i], -1);
		}
		int min = go(0, 0);
		// System.out.println(min);
		print(0, 0);
		System.out.println();
		out.close();
	}

	final static int oo = Integer.MAX_VALUE/2;

	private int go(int pos, int mask) {
		// System.out.println(pos + " " + mask + " " + min);
		if (pos == n) return 0;
		if (dp[pos][mask] != -1) return dp[pos][mask];

		int ret = oo;
		for(int i=1;i<MAXN;i++){
			if ((mask & msk[i]) > 0) continue;
			int lmin = Math.min(ret, go(pos + 1, mask | msk[i]) + Math.abs(a[pos] - i));
			if (ret > lmin) {
				ret = lmin;
				// from[pos][mask] = msk[i];
				from[pos][mask] = (byte)i;
			}
		}

		return dp[pos][mask] = ret;
	}

	private void print(int pos, int mask) {
		if (pos == n) return;
		// int next = from[pos][mask];
		System.out.print(from[pos][mask] + " ");
		mask|=msk[from[pos][mask]];
		print(pos + 1, mask);
	}

	private int factorize(int X) {
		int x = X;
		int mask = 0;
		for(int i=2;i*i<=x;i++){
			if (x % i == 0) {
				mask|=1<<map.get(i);
				while(x % i == 0) x/=i;
			}
		}

		if (x > 1) mask|=1<<map.get(x);

		// System.out.println(X);
		// for(int i=0;i<map.size();i++){
		// 	if ((mask & (1 << i)) > 0) {
		// 		System.out.print(cnv[i] + ", ");
		// 	}
		// }
		// System.out.println();

		return mask;
	}

	private boolean isPrime(int x) {
		for(int i=2;i*i<=x;i++) if (x % i == 0) return false;
		return true;
	}
		
	public static void main(String[] args) throws Exception{
		new Main().run();
	}
}