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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author NMouad21
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FReader in = new FReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        private final int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59 };
        private int     n;
        private int[]   a;
        private int[]   nmask;
        private int[][] dp;
        private int[][] nxt;

        public void solve(int testNumber, FReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            dp = new int[n][1 << primes.length];
            nxt = new int[n][1 << primes.length];

            for(int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                Arrays.fill(dp[i], -1);
                Arrays.fill(nxt[i], 1);
            }

            nmask = new int[60];
            for(int i = 2; i < 60; ++i) {
                for(int j = 0; j < primes.length; ++j) {
                    if(i % primes[j] == 0) {
                        nmask[i] |= (1 << j);
                    }
                }
            }

            solve(0, 0);
            for(int i = 0, mask = 0; i < n; ++i) {
                out.print(nxt[i][mask]);
                out.print(' ');
                mask |= nmask[nxt[i][mask]];
            }
        }

        private int solve(int i, int mask) {
            if(i == n) return 0;
            if(dp[i][mask] >= 0) return dp[i][mask];

            int ans = Math.abs(1 - a[i]) + solve(i + 1, mask); // to "1"
            for(int k = 2; k <= 59; ++k) {
                if((nmask[k] & mask) == 0) {
                    int pans = Math.abs(k - a[i]) + solve(i + 1, nmask[k] | mask);
                    if(pans < ans) {
                        ans = pans;
                        nxt[i][mask] = k;
                    }
                }
            }

            return dp[i][mask] = ans;
        }

    }

    static class FReader {
        private BufferedReader  r;
        private String          line;
        private StringTokenizer st;
        private String          token;

        public FReader() {
            this(System.in);
        }

        public FReader(InputStream i) {
            r = new BufferedReader(new InputStreamReader(i));
        }

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

        private String peekToken() {
            if(token == null)
                try {
                    while(st == null || !st.hasMoreTokens()) {
                        line = r.readLine();
                        if(line == null) return null;
                        st = new StringTokenizer(line);
                    }
                    token = st.nextToken();
                } catch(IOException e) { }
            return token;
        }

        private String nextToken() {
            String ans = peekToken();
            token = null;
            return ans;
        }

    }
}