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 
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.util.LinkedList;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        R259B solver = new R259B();
        solver.solve(1, in, out);
        out.close();
    }

    static class R259B {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {

            int MAXNUM = 59;
            int[] primes = new int[16];
            int pi = 0;
            int[] masks = new int[MAXNUM];
            for (int i = 2; i < MAXNUM; i++) {
                boolean prime = true;
                for (int div = 2; div * div <= i; div++) {
                    if (i % div == 0) {
                        prime = false;
                        break;
                    }
                }
                if (prime)
                    primes[pi++] = i;
            }
            for (int i = 1; i < MAXNUM; i++) {
                int mask = 0;
                for (int j = 0; j < 16; j++) {
                    if (i % primes[j] == 0) {
                        mask |= 1 << j;
                    }
                }
                masks[i] = mask;
                //System.out.println("i = " + i);
                //System.out.println("mask = " + Integer.toBinaryString(mask));
            }
            int n = in.ni();
            int[] a = in.na(n);
            int[][] dp = new int[n + 1][1 << 16];
            int[][] p = new int[n + 1][1 << 16];
            for (int i = 0; i < n + 1; i++) {
                Arrays.fill(dp[i], Integer.MAX_VALUE);
            }
            dp[0][0] = 0;
            int all1 = (1 << 16) - 1;
            for (int i = 0; i < n; i++) {
                for (int j = 1; j < MAXNUM; j++) {
                    int rmask = all1 - masks[j];
                    int abs = Math.abs(a[i] - j);
                    for (int smask = rmask; smask >= 0; smask = (smask - 1) & rmask) {
                        if (dp[i][smask] != Integer.MAX_VALUE) {
                            if (dp[i][smask] + abs < dp[i + 1][smask | masks[j]]) {
                                dp[i + 1][smask | masks[j]] = dp[i][smask] + abs;
                                p[i + 1][smask | masks[j]] = j;
                            }
                        }
                        if (smask == 0) break;
                    }
                }
            }
            int ans = Integer.MAX_VALUE;
            int mask = 0;
            for (int i = 0; i < 1 << 16; i++) {
                if (dp[n][i] < ans) {
                    ans = dp[n][i];
                    mask = i;
                }
            }
            LinkedList<Integer> list = new LinkedList<>();
            for (int i = n; i > 0; i--) {
                list.push(p[i][mask]);
                if (p[i][mask] != 1)
                    mask ^= masks[p[i][mask]];
            }
            for (int num : list) {
                out.print(num + " ");
            }
            out.println();
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}

