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.*;
import java.io.*;
public class EdA {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		
 		int[] array = new int[n];
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		for(int j =0;j<n;j++){
 			array[j] = Integer.parseInt(st.nextToken());
 		}
 		if (n == 1)
 			out.println(array[0]);
 		else{
 		long[][] dp = new long[n][131072];
 		for(int j = 0;j<n;j++){
 			Arrays.fill(dp[j], Integer.MAX_VALUE);
 		}
 		ArrayList<Integer> primes = new ArrayList<Integer>();
 		primes.add(2);
 		primes.add(3);
 		primes.add(5);
 		primes.add(7);
 		primes.add(11);
 		primes.add(13);
 		primes.add(17);
 		primes.add(19);
 		primes.add(23);
 		primes.add(29);
 		primes.add(31);
 		primes.add(37);
 		primes.add(41);
 		primes.add(43);
 		primes.add(47);
 		primes.add(53);
 		primes.add(59);
 		Map<Integer, Integer> bitmask = new HashMap<Integer, Integer>();
 		for(int j = 1;j<=60;j++){
 			int mask = 0;
 			int pow = 1;
 			for(int k =0;k<primes.size();k++){
 				if (j%primes.get(k) == 0)
 					mask+=pow;
 				pow*=2;
 			}
 			bitmask.put(j,  mask);
 		}
 		for(int j = 1;j<=60;j++)
 			dp[0][bitmask.get(j)] = Math.abs(array[0]-j);
 		for (int j = 1;j<n;j++){
 			for (int k=1;k<=60;k++){
 				int x = 131071^bitmask.get(k);
 				int s = x;
 				while(true){
 					int y = s | bitmask.get(k);
 					dp[j][y] = Math.min(dp[j][y], dp[j-1][s]+Math.abs(array[j]-k));
 					if (s == 0)
 						break;
 					s = (s-1)&x;
 				}
 			}
 		}
 		int currmin = Integer.MAX_VALUE;
		int index = -1;
		for(int k = 0;k<131072;k++){
			if (dp[n-1][k] < currmin){
				currmin = (int)(dp[n-1][k]);
				index = k;
			}
		}

 		ArrayList<Integer> backwards = new ArrayList<Integer>();
 		long ans = Integer.MAX_VALUE;
 		for(int j=n-1;j>=0;j--){

 			
 			int min2 = Integer.MAX_VALUE;
 			int index2 = -1;
 			for(int k=1;k<=60;k++){
 				if ((index | bitmask.get(k)) == index && (j == 0 ? 0 : dp[j-1][index-bitmask.get(k)]) + Math.abs(array[j]-k) < min2){
 					min2 = (j == 0 ? 0 : (int)(dp[j-1][index-bitmask.get(k)])) + Math.abs(array[j]-k);
 					index2 = k;
 				}
 			}
 			backwards.add(index2);
 			index-=bitmask.get(index2);
 		}
 		for(int j =backwards.size()-1;j>=0;j--){
 			out.print(backwards.get(j) + " ");
 		}
 		}
 		out.println();
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is