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:
//package cf258;

import java.util.*;
import java.io.*;

public class B {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		int[] primes = new int[16];
		int c = 0;
		for (int i = 2; i < 59; i++) {
			boolean f = true;
			for (int j = 2; j <= Math.sqrt(i); j++) {
				if (i % j == 0) {
					f = false;
				}
			}
			if (f) {
				primes[c] = i;
				c++;
			}
		}

		int[][] pp = new int[60][16];
		for (int i = 0; i < 60; i++) {
			for (int j = 0; j < 16; j++) {
				pp[i][j] = -1;
			}
		}
		for (int i = 2; i < 60; i++) {
			int k = 0;
			for (int j = 0; j < 16; j++) {
				if (i % primes[j] == 0) {
					pp[i][k] = j;
					k++;
				}
			}
		}

		int maxMask = 1 << 16;
		int[][] dp = new int[100][maxMask];
		int[][] last = new int[n][maxMask];

		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < maxMask; j++) {
				dp[i][j] = 10000000;
			}
		}

		for (int i = 0; i < n; i++) {
			for (int mask = 0; mask < maxMask; mask++) {
				for (int cur = 1; cur < 59; cur++) {
					boolean can = true;
					int k = 0;
					int newMask = mask;
					while ((pp[cur][k] != -1) && can) {
						if ((mask & (1 << pp[cur][k])) > 0) {
							can = false;
							break;
						}
						newMask |= 1 << pp[cur][k];
						k++;
					}
					if (can) {
						if ((Math.abs(cur - a[i]) + (i == 0 ? (mask == 0 ? 0 : 100000) : dp[i - 1][mask])) < dp[i][newMask]) {
							dp[i][newMask] = Math.abs(cur - a[i]) + (i == 0 ? 0 : dp[i - 1][mask]);
							last[i][newMask] = cur;
						}
					}
				}
			}
		}

		int ans = 1000000;
		int goodMask = 0;
		for (int mask = 0; mask < maxMask; mask++) {
			if (dp[n - 1][mask] < ans) {
				ans = dp[n - 1][mask];
				goodMask = mask;
			}
		}
		int[] aans = new int[n];
		int cc = n - 1;
		while (cc >= 0) {
			aans[cc] = last[cc][goodMask];
			int cur = aans[cc];
			int k = 0;
			while ((pp[cur][k] != -1)) {
				goodMask &= ~(1 << pp[cur][k]);
				k++;
			}
			cc--;
		}
		for (int i = 0; i < n; i++) {
			System.out.print(aans[i] + " ");
		}
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] arg) {
		new B().run();
	}
}