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.InputMismatchException;
import java.io.IOException;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BLittlePonyAndHarmonyChest solver = new BLittlePonyAndHarmonyChest();
        solver.solve(1, in, out);
        out.close();
    }

    static class BLittlePonyAndHarmonyChest {
        int[][] dp;
        int[] a;
        int n;
        int[] primes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61};
        int[] fact;
        int[] seq;
        int[][] best;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.readInt();
            a = in.readIntArray(n);
            dp = new int[n][1 << 17];
            for (int[] i : dp) Arrays.fill(i, -1);
            seq = new int[n];
            best = new int[n + 1][1 << 17];

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

            int ans = go(0, 0);

            int mask = 0;
            for (int i = 0; i < n; i++) {
                seq[i] = best[i][mask];
                mask |= fact[seq[i]];
            }

            for (int i : seq) out.print(i + " ");
        }

        int go(int pos, int mask) {
            if (pos >= n) return 0;
            if (dp[pos][mask] != -1) return dp[pos][mask];

            int ans = Integer.MAX_VALUE;
            l1:
            for (int i = 1; i <= 60; i++) {
                if ((fact[i] & mask) != 0) continue;

                int v = go(pos + 1, mask | fact[i]);
                v += Math.abs(a[pos] - i);
                if (ans > v) {
                    ans = v;
                    best[pos][mask] = i;
                }
            }
            return dp[pos][mask] = ans;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] ans = new int[size];
            for (int i = 0; i < size; i++) ans[i] = readInt();
            return ans;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}