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.IOException;
import java.io.InputStreamReader;
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
 */
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 {
        static int n;
        static int[] arr;
        static int[] primeFac;
        static int[][] memo;
        static PrintWriter pww = new PrintWriter(System.out);

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = sc.nextInt();
            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) + 1];
            for (int[] x : memo)
                Arrays.fill(x, -1);
            primeFac = new int[61];
            for (int i = 0; i < primeFac.length; ++i) {
                for (int j = 0, k = 0; j < isPrime.length; ++j) {
                    if (isPrime[j]) {
                        if (i % j == 0)
                            primeFac[i] |= 1 << k;
                        ++k;
                    }
                }
            }
            trace(0, 0);
            pww.close();
        }

        private void trace(int idx, int msk) {
            if (idx == n)
                return;
            int cur = dp(idx, msk);
            for (int i = 1; i <= 60; i++) {
                if (((msk) & primeFac[i]) == 0 && cur == dp(idx + 1, msk | primeFac[i]) + Math.abs(arr[idx] - i)) {
                    pww.print(i + " ");
                    trace(idx + 1, msk | primeFac[i]);
                    return;
                }
            }
        }

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

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

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

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

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

    }
}