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.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

import org.omg.CosNaming.IstringHelper;

public class Main
{

	public static void main(String[] args) throws IOException
	{

		Main main = new Main();
		main.read();
	}

	/* IO */
	private InputReader in;
	private StringBuilder ans;

	/* fields */
	int max = 58;
	private int[] masks;
	private HashMap<Integer, Integer> primeToIndex;
	private int n;
	private int[] arr;
	private int[][] dp;
	private int[][] stateResult;
	private int[][] stateNextMask;

	private void read() throws IOException
	{
		// streams
		boolean file = false;
		if (file)
			in = new InputReader(new FileInputStream("Input.txt"));
		else
			in = new InputReader(System.in);
		ans = new StringBuilder();

		// precompute
		generateMasks();

		// read
		n = Integer.parseInt(in.next());
		arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = Integer.parseInt(in.next());

		// solve
		System.out.println(solve());

	}

	private String solve()
	{
		// clear mem
		int nPrimes = primeToIndex.size();
		dp = new int[n][(1 << nPrimes)];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < (1 << nPrimes); j++)
				dp[i][j] = -1;
		stateResult = new int[n][(1 << nPrimes)];
		stateNextMask = new int[n][1 << nPrimes];

		// form answer
		f(0, 0);
		StringBuilder strb = new StringBuilder();
		int mask = 0;
		for (int idx = 0; idx < n; idx++)
		{
			strb.append(stateResult[idx][mask] + " ");
			mask = stateNextMask[idx][mask];
		}
		return strb.toString().trim();
	}

	private int f(int idx, int mask)
	{
		// base case
		if (idx == n)
			return 0;
		if (dp[idx][mask] != -1)
			return dp[idx][mask];

		// try all numbers
		int min = Integer.MAX_VALUE;
		for (int x = 1; x <= max; x++)
			if ((masks[x] & mask) == 0)
			{
				int cost = Math.abs(arr[idx] - x) + f(idx + 1, mask | masks[x]);
				if (cost < min)
				{
					min = cost;
					stateResult[idx][mask] = x;
					stateNextMask[idx][mask] = (mask | masks[x]);
				}
				min = Math.min(min, Math.abs(arr[idx] - x) + f(idx + 1, mask | masks[x]));
			}

		return dp[idx][mask] = min;
	}

	private void generateMasks()
	{
		// find primes
		boolean[] isPrime = new boolean[max + 1];
		Arrays.fill(isPrime, true);
		for (int i = 2; i <= max; i++)
			if (isPrime[i])
				for (int j = i + i; j <= max; j += i)
					isPrime[j] = false;

		// index each prime
		int curr = 0;
		primeToIndex = new HashMap<Integer, Integer>();
		for (int i = 2; i <= max; i++)
			if (isPrime[i])
				primeToIndex.put(i, (curr++));

		// fill masks
		masks = new int[max + 1];
		for (int i = 1; i <= max; i++)
			masks[i] = getMask(i);
	}

	private int getMask(int x)
	{
		int mask = 0;
		for (int i = 2; i <= max; i++)
			while (x % i == 0)
			{
				mask |= (1 << primeToIndex.get(i));
				x /= i;
			}
		return mask;
	}

}

class InputReader
{
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream)
	{
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next()
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
		{
			try
			{
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e)
			{
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

}