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

public class A {
	BufferedReader in; 
	PrintWriter out;
	StringTokenizer st; 


	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch(Exception e) {}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next()); 
	}

	public long nextLong() {
		return Long.parseLong(next());
	}
	public double nextDouble() {
		return Double.parseDouble(next()); 
	}

	boolean bit(int m, int i) {
		return (m & (1 << i)) > 0; 
	}


	void db(String ss){
		System.err.println(ss);
	} 

	long gcd(long a, long b) {
		return b==0 ? a : gcd(b, a % b);
	}

	long lcm(long a, long b, long c) {
		a = a/(gcd(a, b))* b;
		long d = gcd(a,c);
		return a/d*c; 
	}

	double power(double a, int b) {
		if (b == 0) return 1; 
		if (b == 1) return a;
		if (b % 2 == 0) {
			double d = power(a, b/2);
			return d * d; 
		} else {
			return a * power(a, b-1);
		}
	}

	int[] p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59};
	short inf = 10000; 

	public void run() {
		in  = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
			int n = nextInt(); 
			short[] a = new short[n];
			for (int i=0; i<n; i++) a[i] = (short)nextInt();
			int[] pm = new int[65]; 
			for (int i=2; i<65; i++) {
				for (int j=0; j<p.length; j++) if (i % p[j] == 0) pm[i]+=(1<<j);
			}

			short[][] d = new short[n+1][1<<(p.length)];
			short[][] pre  = new short[n+1][1<<p.length];
			d[0][0] = 0;

			for (int i=0; i<n; i++) {
				int nx = i+1;
				for (int mask = 0; mask<(1<<p.length); mask++) {
					d[nx][mask] = inf;
					pre[nx][mask] = -1; 
				}
			}

			for (int i=0; i<n; i++) {
				int cr = i;
				int nx = i+1;

				for (short j=1; j<=2*a[i]; j++) {
					for (int mask = ((1<<p.length) - 1) & (~pm[j]); ; mask=((mask-1) & (~pm[j]))) {
						if (d[nx][mask | pm[j]] > d[cr][mask] + abs(a[i] - j)) {
							d[nx][mask | pm[j]] = (short)(d[cr][mask] + abs(a[i] - j));
							pre[nx][mask | pm[j]] = j;
						}
						if (mask == 0) break;
					}
				}
			}

			int best = 0;
			for (int i=1; i<(1<<p.length); i++) if (d[n][best] > d[n][i]) best = i;

			int[] b =new int[n]; 
			for (int i=n-1; i>=0; i--) {
				b[i] = pre[i+1][best];
				best ^= pm[b[i]]; 
			}

			for (int i=0; i<n; i++) out.print(b[i] + " ");

		out.close(); 	
	}

	class Pair implements Comparable<Pair> {
		int x,y; 
		public Pair(int x, int y) {
			this.x=x; 
			this.y=y; 
		}
		public int compareTo(Pair o) {
			if (x != o.x) return x - o.x; 
			return o.y - y; 
		}
	}

	int sign(long x) {
		if (x < 0) return -1; 
		if (x > 0) return 1; 
		return 0;
	}

	public static void main(String[] args) throws Exception {
		new A().run(); 		
	}
}