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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;


public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int[]a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = nextInt();
        }
        int[]primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
        int[][]dp = new int[n+1][1 << 16], p = new int[n+1][1 << 16];
        int INF = (int) 1e9;
        for (int i = 0; i <= n; i++) {
            Arrays.fill(dp[i], INF);
        }
        dp[0][0] = 0;
        int[]m = new int[59];
        for (int i = 1; i <= 58; i++) {
            for (int j = 0; j < 16; j++) {
                if (i % primes[j]==0)
                    m[i] |= (1 << j);
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int mask = 0; mask < (1 << 16); mask++) {
                for (int j = 1; j <= 58; j++) {
                    if ((mask & m[j])==0) {
                        if (dp[i-1][mask]+Math.abs(a[i]-j) < dp[i][mask | m[j]]) {
                            dp[i][mask | m[j]] = dp[i-1][mask]+Math.abs(a[i]-j);
                            p[i][mask | m[j]] = j;
                        }
                    }
                }
            }
        }
        int min = INF, last = 0;
        for (int i = 0; i < (1 << 16); i++) {
            if (dp[n][i] < min) {
                min = dp[n][i];
                last = i;
            }
        }
        ArrayList<Integer> ans = new ArrayList<>();
        for (int i = n; i >= 1; i--) {
            ans.add(p[i][last]);
            last ^= m[p[i][last]];
        }
        Collections.reverse(ans);
        for (int i : ans) {
            System.out.print(i+" ");
        }
        pw.close();
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}