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

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

    static class TaskB {
        ArrayList<Integer> primes;
        int[] primeMask;
        int n;
        int[][] dp;
        int[] a;
        int[] b;

        int two(int x) {
            return 1 << x;
        }

        void generateMask(int x) {
            primeMask[x] = 0;
            for (int i = 0; i < primes.size(); i++)
                if (x % primes.get(i) == 0) {
                    primeMask[x] |= two(i);
                }
        }

        int rec(int pos, int mask) {
            if (pos == n)
                return 0;
            int res = dp[pos][mask];
            if (res != -1) return res;
            res = two(28); // large enough
            for (int val = 1; val <= 60; val++)
                if ((primeMask[val] & mask) == 0) {
                    int cost = Math.abs(val - a[pos]);
                    res = Math.min(rec(pos + 1, mask | primeMask[val]) + cost, res);
                }
            return dp[pos][mask] = res;
        }

        void findTheSeq(int optimalCost, int pos, int mask) {
            if (pos == n)
                return;
            for (int val = 1; val <= 60; val++)
                if ((primeMask[val] & mask) == 0) {
                    int cost = Math.abs(val - a[pos]);
                    int curCost = rec(pos + 1, mask | primeMask[val]) + cost;
                    b[pos] = val;
                    if (curCost == optimalCost) {
                        findTheSeq(optimalCost - cost, pos + 1, mask | primeMask[val]);
                        return;
                    }
                }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            boolean[] vis = new boolean[70];
            primes = new ArrayList<Integer>();
            for (int i = 2; i < 60; i++)
                if (vis[i] == false) {
                    primes.add(i);
                    for (int j = i; j < 60; j += i) vis[j] = true;
                }

            primeMask = new int[70];
            for (int i = 2; i <= 60; i++) generateMask(i);


            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();

            dp = new int[n][two(primes.size())];
            for (int[] dp1 : dp) {
                Arrays.fill(dp1, -1);
            }
            int optimalCost = rec(0, 0);

            b = new int[n];
            findTheSeq(optimalCost, 0, 0);
            for (int i = 0; i < n; i++) {
                if (i != 0) out.printf(" ");
                out.printf("%d", b[i]);
            }
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}