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.*;
import java.util.*;
import java.math.*;

public class A implements Runnable {

    public void run() {
        long startTime = System.nanoTime();

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

        int[] p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
        int m = p.length;
        int[] msk = new int[111];
        for (int i = 1; i < msk.length; i++) {
            for (int t = 0; t < m; t++) {
                if (i % p[t] == 0) {
                    msk[i] |= 1 << t;
                }
            }
        }
        int[] all = new int[66];
        int[][] lst = new int[1 << m][];
        for (int i = 0; i < 1 << m; i++) {
            int z = 0;
            for (int y = 1; y <= 58; y++) {
                if ((msk[y] & i) == 0) {
                    all[z++] = y;
                }
            }
            System.arraycopy(all, 0, lst[i] = new int[z], 0, z);
        }

        int[][] f = new int[n + 1][1 << m];
        int[][] h = new int[n + 1][1 << m];
        for (int[] g : f) {
            Arrays.fill(g, Integer.MAX_VALUE);
        }
        f[0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 1 << m; j++) {
                if (f[i][j] != Integer.MAX_VALUE) {
                    for (int y : lst[j]) {
                        int x = msk[y];
                        if (f[i + 1][x | j] > f[i][j] + Math.abs(a[i] - y)) {
                            f[i + 1][x | j] = f[i][j] + Math.abs(a[i] - y);
                            h[i + 1][x | j] = j << 9 | y;
                        }
                    }
                }
            }
        }

        int[] res = new int[n];
        int ind = 0;
        for (int i = 0; i < 1 << m; i++) {
            if (f[n][ind] > f[n][i]) {
                ind = i;
            }
        }
        for (int i = n; i-- > 0;) {
            res[i] = h[i + 1][ind] & 511;
            ind = h[i + 1][ind] >> 9;
        }
        for (int i = 0; i < n; i++) {
            print(res[i] + " ");
        }
        println("");

        if (fileIOMode) {
            System.out.println((System.nanoTime() - startTime) / 1e9);
        }
        out.close();
    }

    //-----------------------------------------------------------------------------------

    private static boolean fileIOMode;
    private static BufferedReader in;
    private static PrintWriter out;
    private static StringTokenizer tokenizer;

    public static void main(String[] args) throws Exception {
        fileIOMode = args.length > 0 && args[0].equals("!");
        if (fileIOMode) {
            in = new BufferedReader(new FileReader("a.in"));
            out = new PrintWriter("a.out");
        } else {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        tokenizer = new StringTokenizer("");

        new Thread(new A()).start();
    }

    private static String nextLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    private static String nextToken() {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    private static int nextInt() {
        return Integer.parseInt(nextToken());
    }

    private static long nextLong() {
        return Long.parseLong(nextToken());
    }

    private static double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    private static BigInteger nextBigInteger() {
        return new BigInteger(nextToken());
    }

    private static void print(Object o) {
        if (fileIOMode) {
            System.out.print(o);
        }
        out.print(o);
    }

    private static void println(Object o) {
        if (fileIOMode) {
            System.out.println(o);
        }
        out.println(o);
    }

    private static void printf(String s, Object... o) {
        if (fileIOMode) {
            System.out.printf(s, o);
        }
        out.printf(s, o);
    }
}