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

public class D {

	static int N,M;
	static int[] a;
	static int[] fact;
	static int[][] dp,nxt,num;
	public static void main(String[] args) {
//		for(int i=0;i<100;i++)
//			System.out.println(20);
		int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
				
		fact = new int[62];
		for(int i=0;i<fact.length;i++){
			for(int j=0;j<primes.length;j++){
				if(i<primes[j]){
					break;
				}
				if(i%primes[j]==0){
					fact[i] += 1<<j;
				}
			}
		}
		N=NI();
		a=new int[N+1];
		for(int i=0;i<N;i++){
			a[i] = NI();
		}
		dp = new int[N+1][1<<primes.length];
		nxt= new int[N+1][1<<primes.length];
		num= new int[N+1][1<<primes.length];
		for(int i=0;i<dp.length;i++){
			Arrays.fill(dp[i], 1<<29);
		}
		dfs(0,0);
		int tmp=0;
		for(int i=0;i<N;i++){
			if(i!=0)System.out.print(" ");
			System.out.print(num[i][tmp]);
			tmp=nxt[i][tmp];
		}
		System.out.println();
		//		for(int i=1;i<dp.length;i++){
//			for(int k=1;k<fact.length;k++){
//				int abs = Math.abs(a[i]-k);
//				int x = ~fact[k]&(1<<17)-1;
//				for (int s = x ; ; s = (s - 1) & x) {
//					if((x|s)>x)continue;
//					if(dp[i][s | fact[k]] > dp[i-1][s]+abs){
//						dp[i][s | fact[k]] = dp[i-1][s]+abs;
//					}
//					if(s==0)break;
//				}
//			}
//		}
	}
	static int dfs(int i,int used){
		if(i==dp.length)return 0;
		if(dp[i][used]!=1<<29){
			return dp[i][used];
		}
		int res = 1<<29;
		for(int j=1;j<fact.length;j++){
			if((used&fact[j])>0)continue;
			int next = used|fact[j];
			int val = Math.abs(j-a[i])+dfs(i+1,next);
			if(res > val){
				res = val;
				num[i][used]=j;
				nxt[i][used]=next;
			}
		}
			
		return dp[i][used]=res;
	}
	static int NI(){
		try {
			int c=System.in.read(),r=0;
			for(;c!='-'&&(c<'0'||'9'<c);)c=System.in.read();
			if(c=='-') return -NI();
			for(;'0'<=c&&c<='9';c=System.in.read())
				r = r * 10 + c - '0';
			return r;
		} catch (Exception e) {
			return -1;
		}
	}
}