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

public class CFB {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    int[] prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
    void solve() throws IOException {
        int n = nextInt();
        int[] arr = nextIntArr(n);
        int[][] dp = new int[1 + n][1 << prime.length];
        int[][] save = new int[1 + n][1 << prime.length];
        int[][] prev = new int[1 + n][1 << prime.length];
        for (int i = 0; i <= n; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        dp[0][0] = 0;
        int limit = 60;
        int[] fact = new int[limit];
        for (int i = 1; i < limit; i++) {
            fact[i] = findFact(i);
        }
        for (int i = 1; i <= n; i++) {
            for (int k = 1; k < limit; k++) {
                int x = (~fact[k]) & ((1 << prime.length) - 1);
                for (int s = x; ; s = (s - 1) & x) {
                    if (dp[i - 1][s] != Integer.MAX_VALUE) {
                        if (dp[i - 1][s] + Math.abs(arr[i - 1] - k) < dp[i][s | fact[k]]) {
                            dp[i][s | fact[k]] = dp[i - 1][s] + Math.abs(arr[i - 1] - k);
                            save[i][s | fact[k]] = k;
                            prev[i][s | fact[k]] = s;
                        }
                    }

                    if (s == 0) {
                        break;
                    }
                }
            }
        }

        int min = -1;
        for (int j = 0; j < (1 << prime.length); j++) {
            if (min == -1) {
                min = dp[n][j];
            }
            else {
                if (dp[n][min] > dp[n][j]) {
                    min = j;
                }
            }
        }

        List<Integer> res = new ArrayList<>();
        int mask = min;
        for (int i = n; i >= 1; i--) {
            res.add(save[i][mask]);
            mask = prev[i][mask];
        }

        Collections.reverse(res);
        for (int i = 0; i < res.size(); i++) {
            out(res.get(i) + " ");
        }
    }

    int findFact(int value) {
        int res = 0;
        for (int i = 0; i < prime.length; i++) {
            while (value % prime[i] == 0) {
                value = value / prime[i];
                res |= 1 << i;
            }
        }

        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        System.out.format("%.9f%n", val);
    }
    public CFB() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFB();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}
