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

public class B implements Runnable{
	public static void main (String[] args) {new Thread(null, new B(), "_cf", 1 << 28).start();}
	
	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int oo = (int)1e9;
		int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
		int len = 1 << primes.length, all = len-1;
		int[] pf = new int[60];
		for(int i = 1; i < 60; i++) {
			int ptr = 0, mask = 0, at = i;
			while(ptr < primes.length && at > 1) {
				while(at % primes[ptr] == 0) {
					at /= primes[ptr];
					mask |= (1 << ptr);
				}
				ptr++;
			}
			pf[i] = mask;
		}
		
		int n = fs.nextInt();
		int[] a = new int[n+1];
		for(int i = 1; i <= n; i++)
			a[i] = fs.nextInt();
		int[][] dp  = new int[n+1][len];
		int[][] ptr = new int[n+1][len];
		int[][] num = new int[n+1][len];
		for(int i = 1; i <= n; i++)
			Arrays.fill(dp[i], oo);
		for(int i = 1; i <= n; i++) {
			//place the number x here
			for(int x = 1; x < 60; x++) {
				int build = all ^ pf[x]; //all the potential masks I can use
				//iterates over all submasks slowly
				for(int mask = build; mask > 0; mask = (mask-1) & build) {
					int nsum = dp[i-1][mask] + Math.abs(x - a[i]);
					int newMask = mask | pf[x];
					if(nsum < dp[i][newMask]) {
						//if going back to this mask is better, save it
						//as well as the number we used
						dp[i][newMask] = nsum;
						ptr[i][newMask] = mask;
						num[i][newMask] = x;
					}
				}
			}
		}
		int res = oo, mask = -1;
		for(int i = 0; i < dp[n].length; i++) {
			if(dp[n][i] < res) {
				res = dp[n][i];
				mask = i;
			}
		}
		int[] ans = new int[n];
		int pos = n;
		while(pos > 0) {
			ans[pos-1] = num[pos][mask];
			mask = ptr[pos--][mask];
		}
		for(int i = 0; i < n; i++) {
			if(i > 0) out.print(" ");
			out.print(ans[i]);
		}
		out.println();
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}