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 div259Dn
{
	BufferedReader in;
	StringTokenizer st;
	PrintWriter ob;
	public static void main(String[] args) throws IOException {
		new div259Dn().run();
	}
	void run() throws IOException  {
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	int pr[]=new int[0];
	int mask[]=new int[101];
	void pre() throws IOException  {
		boolean prime[]=new boolean[61];
		for(int i=2 ; i<61 ; i++) {
			if(prime[i]==false) {
				pr=Arrays.copyOf(pr , pr.length+1);
				pr[pr.length-1]=i;
				for(int j=i+i ; j<=60 ; j+=i ) 
					prime[j]=true;
			}
		}
		for(int i=1 ; i<=60 ; i++) {
			for(int j=0 ; j<pr.length ; j++) {
				if(i%pr[j]==0) 
					mask[i]|=(1<<j);
			}
		}
	}
	int dp[][] , a[] , n , ans[];
	void solve() throws IOException {
		n=ni();
		a=new int[n+1];
		ans=new int[n+1];
		for(int i=1 ; i<=n ; i++) 
			a[i]=ni();
		pre();
		dp=new int[n+1][1<<pr.length+1];
		for(int i=0 ; i<=n ; i++)
			Arrays.fill(dp[i] , -1);
		
		int res = solver(1,0);

		backtrack(1, 0 , res , 0);
		
		for(int i=1 ; i<=n ;i++)
		ob.print(ans[i]+ " ");	
	}
	int solver(int pos , int bitmask) {
		if(pos>n)  return 0;
		else if(dp[pos][bitmask]!=-1)
			return dp[pos][bitmask];
		else {
			int ret=Integer.MAX_VALUE;
			for(int i=1 ; i<=60 ; ++i) {
				if(bitmask==0 || (bitmask & mask[i])==0) {
					int nmask = bitmask | mask[i];
					ret = Math.min (  solver(pos+1 , nmask ) + Math.abs(a[pos]-i) , ret ) ;
				}
			}
			return dp[pos][bitmask] = ret;
		}
	}
	void backtrack(int pos , int bitmask , int tot , int used ) {
		if(pos>n) return ;
		else {
			int flag=0;
			for(int i=1 ; i<=60 ; i++) {
				if(bitmask==0 || (bitmask & mask[i])==0) {
					int nm = bitmask | mask[i];
					int res = solver(pos+1 , nm) + Math.abs(a[pos]-i);
					if(res+used==tot) {
						flag=1;						
						ans[pos]=i;
						backtrack (pos + 1 , nm , tot , used + Math.abs(a[pos]-i));
					}
					if(flag==1) break;
				}
			}

		}
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
}