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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class LittlePonyHarmonyChest {
    
    static final int INF = (int) 1e9;
    
    void solve() {
        int[] primes = getPrimesNoLargerThan(60);
        
        int[] mask = new int[60];
        for (int i = 1; i < 60; i++) {
            for (int j = 0; j < 17; j++) {
                if (i % primes[j] == 0) mask[i] |= 1 << j;
            }
        }
        
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = in.nextInt();
        
        int[][] dp = new int[n + 1][1 << 17];
        int[][] prev = new int[n + 1][1 << 17];
        for (int i = 0; i < n + 1; i++) Arrays.fill(dp[i], INF);
        dp[0][0] = 0;
        
        for (int i = 0; i < n; i++) {
            for (int k = 1; k < 60; k++) {
                int x = (~mask[k]) & ((1 << 17) - 1);
                for (int s = x; s > 0; s = (s - 1) & x) {
                    if (dp[i + 1][s | mask[k]] > dp[i][s] + Math.abs(a[i] - k)) {
                        dp[i + 1][s | mask[k]] = dp[i][s] + Math.abs(a[i] - k);
                        prev[i + 1][s | mask[k]] = k;
                    }
                }
                if (dp[i + 1][mask[k]] > dp[i][0] + Math.abs(a[i] - k)) {
                    dp[i + 1][mask[k]] = dp[i][0] + Math.abs(a[i] - k);
                    prev[i + 1][mask[k]] = k;
                }
            }
        }
        
        int s = 0;
        for (int i = 1; i < 1 << 17; i++) {
            if (dp[n][i] < dp[n][s]) s = i;
        }
        
        int[] b = new int[n];
        for (int i = n - 1; i >= 0; i--) {
            b[i] = prev[i + 1][s];
            s = s ^ mask[b[i]];
        }
        
        for (int i = 0; i < n; i++) {
            if (i > 0) out.print(' ');
            out.print(b[i]);
        }
        out.println();
    }
    
    int[] getPrimesNoLargerThan(int n) {
        boolean[] prime = new boolean[n];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        int sqrt = (int) (Math.sqrt(n) + 0.5);
        for (int i = 2; i <= sqrt; i++) {
            if (prime[i]) {
                for (int j = i * i; j < n; j += i) prime[j] = false;
            }
        }
        
        int cnt = 0;
        for (int i = 0; i < n; i++) if (prime[i]) cnt++;
        
        int[] res = new int[cnt];
        int last = 0;
        for (int i = 0; i < n; i++) if (prime[i]) res[last++] = i;
        
        return res;
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new LittlePonyHarmonyChest().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}