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

public class Main{
    FastScanner in;
    PrintWriter out;

    public boolean prime(int x) {
        if (x <= 1) return false;
        if (x <= 3) return true;
        if (x % 2 == 0) return false;
        int d = 3;
        while (d*d <= x) {
            if (x % d == 0) return false;
            d += 2;
        }
        return true;
    }

    public int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a%b);
    }

    public void solve()
    {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        ArrayList<Integer> plist = new ArrayList<>();
        for (int i = 0; i < 59; i++) {
            if (prime(i))
                plist.add(i);
        }



        int[] mask = new int[59];
        for (int i = 0; i < 59; i++)
            mask[i] = 0;

        for (int i = 2; i < 59; i++) {
            for (int j = 0; j < plist.size(); j++)
            if ((i % plist.get(j)) == 0) {
                mask[i] |= (1<<j);
            }
        }


        int ppow = 1 << plist.size();
        int[][] dp = new int[n][ppow];
        int[][] put = new int[n][ppow];
        int[][] bm = new int[n][ppow];


        for (int i = 0; i < n; i++)
            for (int j = 0; j < ppow; j++)
            dp[i][j] = 1000000;

        for (int i = 1; i < 59; i++) {
            if (dp[0][mask[i]] > Math.abs(a[0] - i)) {
                dp[0][mask[i]] = Math.abs(a[0] - i);
                put[0][mask[i]] = i;
            }
        }

        for (int i = 0; i < n-1; i++)
            for (int j = 0; j < ppow; j++)
            if (dp[i][j] < 1000000000)
                for (int k = 1; k < 59; k++)
                    if ((j & mask[k]) == 0)
                        if (dp[i+1][j|mask[k]] > dp[i][j] + Math.abs(a[i+1]-k)) {

                            dp[i+1][j|mask[k]] = (dp[i][j] + Math.abs(a[i+1]-k));
                            put[i+1][j|mask[k]] = k;
                            bm[i+1][j|mask[k]] = j;
                        }


        int ans = 0;
        for (int i = 0; i < ppow; i++)
        if (dp[n-1][i] < dp[n-1][ans])
            ans = i;

        ArrayList<Integer> lans = new ArrayList<>();
        for (int i = n-1; i >= 0; i--) {
            lans.add(put[i][ans]);
            ans = bm[i][ans];
        }
        Collections.reverse(lans);
        for (int x : lans)
            out.print(x + " ");
    }


    public void run()
    {
        in = new FastScanner();
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }


    public static void main(String[] args) {
        new Main().run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}