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 
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class CF259_Harmony2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new CF259_Harmony2().run();
	}

	int nVals;
	int[] vals, sortedVals;

	static int SEARCH_MAX = 61;

	public void run() {

		Scanner in = new Scanner(System.in);

		nVals = in.nextInt();

		vals = new int[nVals];
		for (int i = 0; i < nVals; i++) {
			vals[i] = in.nextInt();
		}

		sortedVals = Arrays.copyOf(vals, vals.length);
		Arrays.sort(sortedVals);

		int[] res = DP(0, new boolean[SEARCH_MAX]);

		for (int i = 0; i < nVals; i++) {
			// Find it
			int num = -1;
			for (int j = 0; j < nVals; j++) {
				if (sortedVals[j] == vals[i]) {
					num = res[j];
					sortedVals[j] = -77;
					break;
				}
			}
			System.out.print(num + " ");
		}
		System.out.println();
	}

	HashMap<Entry, int[]> cache = new HashMap<Entry, int[]>();

	public int[] DP(int ind, boolean[] unusable) {

		// System.err.println(ind + " -- " + Arrays.toString(unusable));

		int[] retArr = new int[nVals];

		// Base case
		if (ind == nVals) {
			return retArr;
		}

		// Check the cache
		Entry key = new Entry(ind, unusable);
		if(cache.containsKey(key)) {
			return cache.get(key);
		}
		
		// Find the first usable value
		int currVal = -1;
		for (int val = 1; val < unusable.length; val++) {
			if (!unusable[val]) {
				currVal = val;
				break;
			}
		}
		if (currVal == -1) {
			return null;
		}

		boolean[] newUnusable = Arrays.copyOf(unusable, unusable.length);

		// Try recursing without this value
		newUnusable[currVal] = true;
		int[] dontUseSol = DP(ind, newUnusable);
		int dontUseScore = 0;

		if (dontUseSol == null) {
			dontUseScore = Integer.MAX_VALUE;
		} else {
			for (int i = ind; i < nVals; i++) {
				dontUseScore += Math.abs(sortedVals[i] - dontUseSol[i]);
			}
		}

		// Try recursing with this value
		newUnusable[currVal] = false;
		for (int val = currVal; val < newUnusable.length; val++) {
			if (gcd(val, currVal) > 1) {
				newUnusable[val] = true;
			}
		}
		int[] subSol = DP(ind + 1, newUnusable);
		int[] useSol = new int[nVals];
		useSol[ind] = currVal;
		int useScore = Math.abs(sortedVals[ind] - currVal);
		if (subSol == null) {
			useScore = Integer.MAX_VALUE;
		} else {
			for (int i = ind + 1; i < nVals; i++) {
				useSol[i] = subSol[i];
				useScore += Math.abs(sortedVals[i] - subSol[i]);
			}
		}

		int[] res = null;
		if (useScore < dontUseScore) {
			res = useSol;
		} else {
			res = dontUseSol;
		}

		cache.put(key, res);
		return res;
	}

	public static int gcd(int a, int b) {
		while (b != 0) {
			int t = b;
			b = a % b;
			a = t;
		}

		return a;
	}

	public class Entry {

		int ind;
		boolean[] unusable;
		int hashcode;

		public Entry(int ind, boolean[] unusable) {

			this.ind = ind;
			this.unusable = Arrays.copyOf(unusable, unusable.length);

			hashcode = (ind << 10) ^ Arrays.hashCode(unusable);
		}

		@Override
		public int hashCode() {
			return this.hashcode;
		}

		@Override
		public boolean equals(Object o) {
			if (!(o instanceof Entry)) {
				return false;
			}

			Entry other = (Entry) o;
			return this.ind == other.ind
					&& Arrays.equals(this.unusable, other.unusable);
		}
	}

}
