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.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		if (new File("input.txt").exists())
			in = new BufferedReader(new FileReader("input.txt"));
		else
			in = new BufferedReader(new InputStreamReader(System.in));
		if (new File("output.txt").exists())
			out = new PrintWriter("output.txt");
		else
			out = new PrintWriter(System.out);

		solve();

		in.close();
		out.close();
	}

	final int maxn = 111;
	final int maxk = 60;
	final int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 57 };
	final int countPrimes = primes.length;
	final int maskPrimes = (1 << countPrimes) - 1;
	final int inf = Integer.MAX_VALUE / 10;

	int n;
	int a[] = new int[maxn];

	int div[] = new int[maxk];
	int d[][] = new int[maxn][1 << countPrimes];
	int p[][] = new int[maxn][1 << countPrimes];
	int ans[] = new int[maxn];

	void precalc() {
		for (int k = 1; k < maxk; k++) {
			div[k] = 0;
			for (int i = 0; i < countPrimes; i++)
				if (k % primes[i] == 0)
					div[k] |= (1 << i);
		}
	}

	void solve() throws IOException {
		precalc();

		n = nextInt();
		for (int i = 0; i < n; i++)
			a[i] = nextInt();

		for (int i = 0; i < n; i++)
			fill(d[i], inf);
		for (int k = 1; k < maxk; k++)
			if (d[0][div[k]] > abs(a[0] - k)) {
				d[0][div[k]] = abs(a[0] - k);
				p[0][div[k]] = k;
			}

		for (int i = 1; i < n; i++)
			for (int k = 1; k < maxk; k++) {
				int m = div[k] ^ maskPrimes;
				if (d[i][div[k]] > d[i - 1][0] + abs(a[i] - k)) {
					d[i][div[k]] = d[i - 1][0] + abs(a[i] - k);
					p[i][div[k]] = k;
				}
				for (int mask = m; mask > 0; mask = (mask - 1) & m)
					if (d[i][mask | div[k]] > d[i - 1][mask] + abs(a[i] - k)) {
						d[i][mask | div[k]] = d[i - 1][mask] + abs(a[i] - k);
						p[i][mask | div[k]] = k;
					}
			}

		int mask = 0;
		for (int i = 1; i <= maskPrimes; i++)
			if (d[n - 1][i] < d[n - 1][mask]) {
				mask = i;
			}
		for (int i = n - 1; i >= 0; i--) {
			ans[i] = p[i][mask];
			mask ^= div[ans[i]];
		}

		for (int i = 0; i < n; i++)
			out.print(ans[i] + " ");
		out.println();
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String str = in.readLine();
			if (str == null)
				return true;
			st = new StringTokenizer(str);
		}
		return false;
	}

}