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


public class CF453B {

    public static void main(String[] args) throws Exception {
        new CF453B().solve();
    }

    static final int[] primes = {
            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53 };

    static class ElmWithIndex implements Comparable<ElmWithIndex> {
        final int a;
        final int i;
        int v;

        public ElmWithIndex(int a, int i) {
            this.a = a;
            this.i = i;
        }

        @Override
        public int compareTo(ElmWithIndex o) {
            return -Integer.compare(a, o.a);
        }

    }

    private void solve() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ElmWithIndex[] a = new ElmWithIndex[n];
        for (int i = 0; i < n; i++) {
            a[i] = new ElmWithIndex(sc.nextInt(), i);
        }
        Arrays.sort(a);
        int m = Math.min(primes.length, n);
        int[][] dp = new int[m + 1][1 << primes.length];
        int[][] prev = new int[m + 1][1 << primes.length];
        final int INF = 100000;
        for (int i = 0; i <= m; i++) {
            Arrays.fill(dp[i], INF);
        }

        int[] nummask = new int[54];
        for (int i = 1; i < 54; i++) {
            for (int j = 0; j < primes.length; j++) {
                if (i % primes[j] == 0) nummask[i] |= 1 << j;
            }
        }

        dp[0][0] = 0;
        for (int i = 0; i < m; i++) {
            for (int st = 0; st < 1 << primes.length; st++) {
                if (dp[i][st] == INF) continue;
                for (int nv = 1; nv < 54; nv++) {
                    if ((st & nummask[nv]) != 0) continue;
                    int olddp = dp[i + 1][st | nummask[nv]];
                    int newdp = dp[i][st] + Math.abs(a[i].a - nv);
                    if (newdp < olddp) {
                        dp[i + 1][st | nummask[nv]] = dp[i][st] + Math.abs(a[i].a - nv);
                        prev[i + 1][st | nummask[nv]] = st;
                    }
                }
            }
        }
        int ans = INF;
        int ansst = 0;
        for (int st = 0; st < 1 << primes.length; st++) {
            ans = Math.min(ans, dp[m][st]);
            if (ans == dp[m][st]) ansst = st;
        }
        for (int i = m - 1; i >= 0; i--) {
            int stdiff = ansst ^ prev[i + 1][ansst];
            for (int nv = 1; nv < 54; nv++) {
                if (stdiff == nummask[nv]
                        && Math.abs(a[i].a - a[i].v) > Math.abs(a[i].a - nv)) {
                    a[i].v = nv;
                }
            }
            ansst = prev[i + 1][ansst];
        }
        for (int i = m; i < n; i++) {
            a[i].v = 1;
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[j].i == i) System.out.print(a[j].v + " ");
            }
        }
        System.out.println();

    }
}