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.Scanner;

public class Cf453B {
    static int maxVal = 60, inf = 40000;
    static int[] P = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
    int n, bestCost, bestMask, lastVal;
    int[] A, B, fmask;
    int[][] dp, go, val;
    public static void main(String[] args) {
        Cf453B cf = new Cf453B();
        cf.run();
        cf.print();
    }
    public Cf453B() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = new int[n];
        B = new int[n];
        for (int i = 0; i < n; ++i)
            A[i] = sc.nextInt();
        fmask = new int[maxVal];
        dp = new int[n+1][1<<P.length];
        go = new int[n+1][1<<P.length];
        val = new int[n+1][1<<P.length];
        for (int i = 1; i <= n; ++i)
            for (int j = 0; j < (1<<P.length); ++j)
                dp[i][j] = inf;
        for (int i = 2; i < maxVal; ++i) {
            for (int j = 0; j < P.length; ++j)
                if (i % P[j] == 0)
                    fmask[i] |= 1 << j;
        }
    }
    public void run() {
        for (int i = 0; i < n; ++i)
            for (int x = 1; x < maxVal; ++x) {
                int mask = (~fmask[x]) & ((1<<P.length)-1);
                for (int m = mask; m >= 0; --m) {
                    m = m & mask;
                    int nval = Math.abs(A[i]-x) + dp[i][m];
                    if (dp[i+1][m|fmask[x]] > nval) {
                        dp[i+1][m|fmask[x]] = nval;
                        go[i+1][m|fmask[x]] = m;
                        val[i+1][m|fmask[x]] = x;
                    }
                }
            }
        bestCost = inf;
        for (int mask = 0; mask < (1<<P.length); ++mask)
            if (dp[n][mask] < bestCost) {
                bestCost = dp[n][mask];
                bestMask = mask;
                lastVal = go[n][mask];
            }
        for (int i = n; i > 0; --i) {
            B[i-1] = val[i][bestMask];
            bestMask = go[i][bestMask];
        }
    }
    public void print() {
        //System.err.println(bestCost);
        StringBuilder b = new StringBuilder();
        b.append(B[0]);
        for (int i = 1; i < n; ++i) {
            b.append(' ');
            b.append(B[i]);
        }
        System.out.println(b.toString());
    }
}