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.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();

            int MAX = 60;
            boolean isPrime[] = new boolean[MAX];
            Arrays.fill(isPrime, true);
            for (int i = 2; i * i < MAX; i++)
                if (isPrime[i])
                    for (int j = i * i; j < MAX; j += i)
                        isPrime[j] = false;

            ArrayList<Integer> primes = new ArrayList<>();

            for (int i = 2; i < MAX; i++)
                if (isPrime[i]) {
                    primes.add(i);
                }

            int[] primeFactors = new int[59];
            for (int i = 1; i < 60; i++) {
                int mask = 0;
                for (int j = 0; j < primes.size(); j++)
                    if (i % primes.get(j) == 0)
                        mask |= (1 << j);
                primeFactors[i - 1] = mask;
            }

            int sz = primeFactors.length;
            int[][] dp = new int[n][1 << 17];
            for (int[] d : dp) Arrays.fill(d, 5000);

            for (int i = 0; i < sz; i++)
                dp[0][primeFactors[i]] = Math.min(dp[0][primeFactors[i]], Math.abs(arr[0] - (i + 1)));

            for (int i = 1; i < n; i++)
                for (int num = 1; num <= sz; num++) {
                    int PF = primeFactors[num - 1];
                    for (int taken = 0; taken < (1 << 17); taken++) {
                        if ((PF & taken) == PF) {
                            dp[i][taken] = Math.min(dp[i][taken], Math.abs(arr[i] - num) + dp[i - 1][taken ^ PF]);
                        } else continue;
                    }
                }


            int maxMask = 0;
            for (int i = 0; i < (1 << 17); i++)
                if (dp[n - 1][i] < dp[n - 1][maxMask])
                    maxMask = i;

            int curIdx = n - 1, curMask = maxMask;
            ArrayList<Integer> sol = new ArrayList<>();
            while (curIdx > 0) {
                for (int num = 1; num <= sz; num++) {
                    int PF = primeFactors[num - 1];
                    if ((PF & curMask) == PF)
                        if (Math.abs(arr[curIdx] - num) + dp[curIdx - 1][curMask ^ PF] == dp[curIdx][curMask]) {
                            sol.add(num);
                            curMask ^= PF;
                            break;
                        }
                }
                curIdx--;
            }

            int last = 1;
            for (int i = 1; i <= sz; i++)
                if (primeFactors[i - 1] == curMask && (last == 1 || Math.abs(arr[0] - i) < Math.abs(arr[0] - last)))
                    last = i;
            sol.add(last);
            StringBuilder sb = new StringBuilder();
            for (int i = sol.size() - 1; i >= 0; i--)
                sb.append(sol.get(i)).append(" ");
            out.println(sb);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

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

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

    }
}