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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        BLittlePonyAndHarmonyChest solver = new BLittlePonyAndHarmonyChest();
        solver.solve(1, in, out);
        out.close();
    }

    static class BLittlePonyAndHarmonyChest {
        int n;
        int[] arr;
        int[][] memo;
        int[] msks;
        StringBuilder sb;

        public void readInput(Scanner sc) {
            n = sc.nextInt();
            arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
        }

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            readInput(sc);
            boolean[] isPrime = new boolean[61];
            Arrays.fill(isPrime, true);
            isPrime[0] = isPrime[1] = false;
            for (int i = 2; i * i <= 61; i++) {
                if (isPrime[i]) {
                    for (int j = i * i; j < 61; j += i)
                        isPrime[j] = false;
                }
            }
            memo = new int[n][(1 << 17)];
            for (int[] x : memo)
                Arrays.fill(x, -1);
            msks = new int[61];
            for (int i = 0; i < msks.length; ++i) {
                for (int j = 0, k = 0; j < isPrime.length; ++j) {
                    if (isPrime[j]) {
                        if (i % j == 0)
                            msks[i] |= 1 << k;
                        ++k;
                    }
                }
            }
            sb = new StringBuilder();
            trace(0, 0);
            pw.println(sb);
        }

        private void trace(int idx, int msk) {
            if (idx == n)
                return;
            int opt = dp(idx, msk);
            for (int i = 1; i <= 60; i++) {
                if ((msks[i] & msk) == 0) {
                    int cost = Math.abs(arr[idx] - i);
                    if (opt == cost + dp(idx + 1, msk | msks[i])) {
                        sb.append(i + " ");
                        trace(idx + 1, msk | msks[i]);
                        return;
                    }
                }
            }
        }

        private int dp(int idx, int msk) {
            if (idx == n)
                return 0;
            int min = (int) 1e9;
            if (memo[idx][msk] != -1)
                return memo[idx][msk];
            for (int i = 1; i <= 60; i++) {
                if ((msks[i] & msk) == 0) {
                    int cost = Math.abs(arr[idx] - i);
                    min = Math.min(min, cost + dp(idx + 1, msk | msks[i]));
                }
            }
            return memo[idx][msk] = min;
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

    }
}