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

public class kvati {

    public static void main(String[] args) throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out, true);
        new kvati().run(rd, pw);
    }
    
    public void run(BufferedReader rd, PrintWriter pw) throws IOException {
        StringTokenizer st = new StringTokenizer(rd.readLine());
        int n = Integer.parseInt(st.nextToken());
        
        st = new StringTokenizer(rd.readLine());
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i ++)
            a[i] = Integer.parseInt(st.nextToken());
        
        int szp = 0;
        int[] prime = new int[30];
        for (int i = 2; i < 60; i ++){
            boolean ok = true;
            for (int j = 2; j < i; j ++)
                if (i % j == 0) ok = false;
            if (ok) prime[szp ++] = i;
        }
        
        int[] mask = new int[60];
        for (int i = 1; i < 60; i ++){
            for (int j = 0; j < szp; j ++ ){
                if (i % prime[j] == 0) mask[i] |= 1 << j;
            }
        }
        
        int m = 1 << szp;
        int[][] dp = new int[n + 1][m + 1];
        int[][] from = new int[n + 1][m + 1];
        int inf = (int) 1e9;
        
        for (int i = 0; i <= n; i ++)
            for (int j = 0; j <= m; j ++) 
                dp[i][j] = inf;
        
        dp[0][0] = 0;
        for (int i = 0; i < n; i ++){
            for (int j = 0; j < m; j ++){
                if (dp[i][j] == inf) continue;
                for (int k = 1; k < 2 * a[i + 1] && k < 54; k ++){
                    if ((mask[k] & j) > 0) continue;
                    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);
                        from[i + 1][j | mask[k]] = k;
                    }
                }
            }
        }
        
        int d = 0;
        for (int i = 0; i <= m; i ++){
            if (dp[n][d] > dp[n][i]){
                d = i;
            }
        }
        
        int[] ans = new int[n + 1];
        for (int i = n; i > 0; i --){
            ans[i] = from[i][d];
            d = d ^ mask[from[i][d]];
        }

        for (int i = 1; i <= n; i ++)
            pw.print(ans[i] + " ");
        pw.flush();
        
    }

}