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 Main {


	public static class pair implements Comparable<pair>
	{
		int a;
		int b;
		public pair(int pa, int pb)
		{
			a = pa; b= pb;
		}
		@Override
		public int compareTo(pair o) {
			if(this.a < o.a)
				return -1;
			if(this.a > o.a)
				return 1;
			return Integer.compare(o.b, this.b);
		}
	}


	//int n = Integer.parseInt(in.readLine());
	//String[] spl = in.readLine().split(" ");

	public static void main (String[] args) throws Exception
	{	
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		int[] prim = { 2,3,5,7 ,11, 13,17,19,23, 29 ,31,37,41 , 43 , 47 , 53, 59};
		int[] div = new int[65];
		for (int i = 2; i < div.length; i++) {
			for (int j = 0; j < prim.length; j++) {
				if(i%prim[j]==0)
				{
					div[i] |= (1<<j);
				}
			}
		}
		String[] spl = in.readLine().split(" ");
		int[] a = new int[n];
		for(int i=0;i<n;i++)a[i] = Integer.parseInt(spl[i]);
		int[][] dp = new int[n+1][1<<prim.length];
		int[][] l = new int[n+1][1<<prim.length];
		for (int i = 1; i < dp.length; i++) {
			for (int j = 0; j < dp[0].length; j++) {
				dp[i][j] = Integer.MAX_VALUE;
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j < (1<<prim.length); j++) {
				for (int dist = 0; dist < 30; dist++) {
					for (int sig = 1; sig >= -1; sig-=2) {
						int cur = a[i-1]+dist*sig;
						if(cur < 1) continue;
						int pc = div[cur];
						if((pc & j) ==0)
						{
							if(dp[i][pc | j] > dp[i-1][j]+dist)	
							{
								dp[i][pc | j] = dp[i-1][j]+dist;
								l[i][pc | j] = cur;
							}
						}
					}
				}
			}
		}
		int[] arr = new int[n];
		int subs = (1<<prim.length)-1;
		for (int i = n; i>0; i--) {
			arr[i-1] = l[i][subs];
			subs = subs & ~(div[arr[i-1]]);
		}
		for (int i = 0; i < n; i++) {
			System.out.print(arr[i]);
			if(i<n-1)
				System.out.print(" ");
		}
		System.out.println();
	}
}