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

public class P453B
{
	static int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
	static int[] extraPrimes = {31, 37, 41, 43, 47, 53};
	static HashSet<Integer> isPrime = new HashSet<>();
	static int[] divisors = new int[54];
	static int oo = Integer.MAX_VALUE/2;
	public static void main(String[] args)
	{
		for (int i = 2; i < 60; i++)
		{
			if (BigInteger.valueOf(i).isProbablePrime(100))
				isPrime.add(i);
		}
		for (int i = 2; i < divisors.length; i++)
		{
			int bitmask = 0;
			for (int j = 0; j < primes.length; j++)
			{
				if (i % primes[j] == 0)
					bitmask |= 1 << j;
			}
			divisors[i] = bitmask;
		}
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = scan.nextInt();
		int[][][] dp = new int[n+1][1 << 10][7]; //2, 3, 5, 7, 11, 13, 17, 19, 23, 29 (10 primes). If the number is > 30, we use them in order (31, 37, ...)
		for (int[][] a : dp)
			for (int[] b : a)
				Arrays.fill(b, oo);
		for (int[] a : dp[0])
			Arrays.fill(a, 0);
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < 1024; j++)
			{
				for (int k = 0; k < 7; k++)
				{
					int prevBest = dp[i][j][k];
					if (prevBest >= oo)
						continue;
					for (int m = 1; m <= 53; m++)
					{
						if ((divisors[m] & j) != 0)
							continue;
						if (m > 30 && isPrime.contains(m))
						{
							if (k == 6)
								continue;
							if (m == extraPrimes[k])
								dp[i+1][j][k+1] = Math.min(dp[i+1][j][k+1], prevBest+Math.abs(arr[i]-m));
						}
						else
							dp[i+1][j|divisors[m]][k] = Math.min(dp[i+1][j|divisors[m]][k], prevBest+Math.abs(arr[i]-m));
					}
				}
			}
		}
		int min = oo;
		int currMask = -1, currExtra = -1;
		for (int i = 0; i < 1024; i++)
		{
			for (int j = 0; j < 7; j++)
			{
				if (dp[n][i][j] < min)
				{
					min = dp[n][i][j];
					currMask = i;
					currExtra = j;
				}
			}
		}
		int currChanges = min;
		int[] ans = new int[n];
		for (int i = n-1; i >= 0; i--)
		{
			for (int m = 1; m <= 53; m++)
			{
				int maskCnt = Integer.bitCount(currMask);
				int divCnt = Integer.bitCount(divisors[m]);
				int diffCnt = Integer.bitCount(currMask^divisors[m]);
				if (maskCnt - divCnt != diffCnt)
					continue;
				int prevMask = currMask^divisors[m];
				
				if (dp[i][prevMask][currExtra] == currChanges-Math.abs(arr[i]-m) && (m < 30 || !isPrime.contains(m)))
				{
					ans[i] = m;
					currChanges = dp[i][prevMask][currExtra];
					currMask = prevMask;
					//currExtra = currExtra
					break;
				}
				if (currExtra > 0)
				{
					if (m == extraPrimes[currExtra-1])
					{
						if (dp[i][prevMask][currExtra-1] == currChanges-Math.abs(arr[i]-m))
						{
							ans[i] = m;
							currChanges = dp[i][prevMask][currExtra-1];
							currMask = prevMask;
							currExtra--;
							break;
						}
					}
				}
			}
		}
		for (int i = 0; i < ans.length; i++)
			System.out.print(ans[i] + " ");
	}
}