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 java.io.*;
import java.util.*;
public class Sol2{
	public static void main(String[] args) throws IOException{
		FastIO sc = new FastIO(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int arr[] = new int[n];
		for(int i=0; i<n; i++) {
			arr[i] = sc.nextInt();
		}
		ArrayList<Integer> prime = new ArrayList<>();
		prime.add(2); 
		prime.add(3); 
		prime.add(5);
		prime.add(7);
		prime.add(11); 
		prime.add(13); 
		prime.add(17); 
		prime.add(19);
		prime.add(23);
		prime.add(29);
		prime.add(31);
		prime.add(37);
		prime.add(41);
		prime.add(43);
		prime.add(47);
		prime.add(53);
		prime.add(59);
		int factor[] = new int[60];
		for(int i=1; i<60; i++) {
			for(int j:prime) {
				int k = i;
				if(k%j==0) {
					factor[i]+=(1<<(prime.indexOf(j)));
					while(k%j==0) {
						k=k/j;
					}
				}
			}
		}
		int b[] = new int[n+1];
		int min = Integer.MAX_VALUE;
		int dp[][] = new int[n+1][(1<<17)];
		int mem[][] = new int[n+1][(1<<17)];
		Arrays.fill(dp[0], 0);
		for(int i=1; i<=n; i++) {
			Arrays.fill(dp[i], Integer.MAX_VALUE);
		}
		int best = 0;
		for(int i=1; i<=n; i++) {
			for(int j=1; j<60; j++) {
				int x = ((1<<17)-1)&(~factor[j]);
				for(int s=x; s>0; s=((s-1)&x)) {
					if(dp[i-1][s]+Math.abs(arr[i-1]-j)<dp[i][s|factor[j]]) {
						dp[i][s|factor[j]] = dp[i-1][s] + Math.abs(arr[i-1]-j);
						mem[i][s|factor[j]] = j;
					}
					if(i==n) {
						if(dp[i][s|factor[j]]<min) {
							min = dp[i][s|factor[j]];
							best = (s|factor[j]);
						}
					}
					if(s==0) break;
				}
			}
		}
		for(int i=n; i>0; i--) {
			b[i] = mem[i][best];
			best^=factor[b[i]];
			//System.out.println(b[i] + " jfpiwof");
		} 
		for(int i=1; i<n; i++) {
			out.print(b[i] + " ");
		}
		out.println(b[n]);
		out.close();
	}
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	static class FastIO {
		 
		// Is your Fast I/O being bad?
 
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
 
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
 
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
 
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
 
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
 
		String next() throws Exception {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
 
	}
}

