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.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * Created by hama_du on 2014/08/02.
 */
public class ProblemB {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] a = new int[n][3];
        for (int i = 0 ; i < n ; i++) {
            a[i][1] = i;
            a[i][0] = in.nextInt();
        }
        Arrays.sort(a, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o2[0];
            }
        });
        for (int j = 0 ; j < n ; j++) {
            a[j][2] = j;
        }


        int[] sp = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
        int[] lp = {31, 37, 41, 43, 47, 53, 59, -1};
        int[] ptn = new int[61];
        for (int i = 2 ; i <= 60 ; i++) {
            for (int si = 0 ; si < sp.length ; si++) {
                if (i % sp[si] == 0) {
                    ptn[i] |= 1<<si;
                }
            }
        }


        int[][][] dp = new int[n+1][1<<10][8];
        for (int i = 0 ; i <= n ; i++) {
            for (int j =  0 ; j < (1<<10) ; j++) {
                Arrays.fill(dp[i][j], Integer.MAX_VALUE);
            }
        }
        int[][][][] dp_prev = new int[n+1][1<<10][8][4];
        dp[0][0][0] = 0;

        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < (1<<10) ; j++) {
                for (int k = 0 ; k < 8 ; k++) {
                    if (dp[i][j][k] == Integer.MAX_VALUE) {
                        continue;
                    }
                    int nextLarge = lp[k];
                    int base = dp[i][j][k];
                    for (int to = 1 ; to <= 60 ; to++) {
                        int tc = base + Math.abs(a[i][0] - to);
                        if ((j & ptn[to]) != 0) {
                            continue;
                        }
                        int tj = j | ptn[to];
                        int tk = k;
                        if (ptn[to] == 0 && to != 1) {
                            if (to != nextLarge) {
                                continue;
                            }
                            tk++;
                        }
                        if (dp[i+1][tj][tk] > tc) {
                            dp[i+1][tj][tk] = tc;
                            dp_prev[i+1][tj][tk][0] = i;
                            dp_prev[i+1][tj][tk][1] = j;
                            dp_prev[i+1][tj][tk][2] = k;
                            dp_prev[i+1][tj][tk][3] = to;
                        }
                    }
                }
            }
        }

        //
        int best = Integer.MAX_VALUE;
        int ni = n;
        int nj = 0;
        int nk = 0;
        for (int j = 0 ; j < (1<<10) ; j++) {
            for (int k = 0; k < 8; k++) {
                if (dp[n][j][k] < best) {
                    best = dp[n][j][k];
                    nj = j;
                    nk = k;
                }
            }
        }

        int[] numbers = new int[n];
        while (ni >= 1) {
            int ti = dp_prev[ni][nj][nk][0];
            int tj = dp_prev[ni][nj][nk][1];
            int tk = dp_prev[ni][nj][nk][2];
            numbers[ni-1] = dp_prev[ni][nj][nk][3];
            ni = ti;
            nj = tj;
            nk = tk;
        }

        int[] answers = new int[n];
        for (int i = 0 ; i < n ; i++) {
            answers[a[i][1]] = numbers[i];
        }
        StringBuilder answer = new StringBuilder();
        for (int i = 0 ; i < n ; i++) {
            answer.append(' ').append(answers[i]);
        }
        System.out.println(answer.substring(1));
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}