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 A{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		n=sc.nextInt();
		a=new int [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		
		ArrayList<Integer> primes=new ArrayList<>();
		boolean [] isComp=new boolean [60];
		for(int i=2;i<60;i++)
			if(!isComp[i]) {
				primes.add(i);
				for(int j=2*i;j<60;j+=i)
					isComp[j]=true;
			}
		pf=new int [60];
		for(int i=2;i<60;i++)
			for(int j=0;j<primes.size();j++)
				if(i%primes.get(j)==0)
					pf[i] |=(1<<j);
		mem=new int [n][1<<17];
		for(int [] x : mem)
			Arrays.fill(x, -1);
		print(0, 0);
		pw.flush();
		pw.close();
    }
	
	static int n;
	static int [] a,pf;
	static int [][] mem;
	
	static void print(int i,int msk) {
		if(i==n)
			return;
		int best=dp(i, msk);
		for(int j=1;j<60;j++)
			if((pf[j] & msk)==0 && Math.abs(j-a[i])+dp(i+1, msk | pf[j])==best) {
				System.out.print(j+" ");
				print(i+1, msk | pf[j]);
				break;
			}
	}
	
	static int dp(int i,int msk) {
		if(i==n)
			return 0;
		if(mem[i][msk]!=-1)
			return mem[i][msk];
		int ans=100000;
		for(int j=1;j<60;j++)
			if((pf[j] & msk)==0)
				ans=Math.min(ans, Math.abs(j-a[i])+dp(i+1, msk | pf[j]));
		return mem[i][msk]=ans;
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}