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.util.Arrays;
import java.util.StringTokenizer;


public class Round259_B {

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

    int N;
    int[] arr;
    int[] factors;
    int[][] memo;
    int[][][]chosen;
    
    public int go(int index, int mask){
        if(index == N){
            return 0;
        }
        
        if(memo[index][mask] != -1){
            return memo[index][mask];
        }
        int ret = Math.abs(arr[index]-1)+go(index+1, mask);
        chosen[0][index][mask] = 1;
        chosen[1][index][mask] = mask;
        

        for(int k = 2;k < 59;k++){
            if((mask&(factors[k])) != 0)continue;
            int tmp = Math.abs(arr[index]-k)+go(index+1, mask|factors[k]);
            if(tmp < ret){
                chosen[0][index][mask] = k;
                chosen[1][index][mask] = mask|factors[k];
                ret = tmp;
            }
        }
        return memo[index][mask] = ret;
    }
    
    public void solve() throws Exception{

        InputReader in = new InputReader();
        N = in.nextInt();
        arr = new int[N];
        for(int i =0;i < N;i++){
            arr[i] = in.nextInt();
        }
        
        memo = new int[N+2][(1<<M)+5];
        for(int i =0;i < memo.length;i++){
            Arrays.fill(memo[i], -1);
        }
        chosen = new int[2][N+2][(1<<M)+5];
        
        
        factors = new int[62];
        for(int i =1;i < factors.length;i++){
            int j =0;
            int val = i;
            for(int x:primes){
                if(val%x == 0){
                    do{
                        val/= x;
                    }while(val%x == 0);
                    factors[i] |= (1<<j);
                }
                ++j;
            }
        }

        go(0,0);
        StringBuffer ans = new StringBuffer();
        for(int mask =0, index =0; index < N;mask=chosen[1][index][mask],index++){
            ans.append(""+chosen[0][index][mask]);
            ans.append((index == N-1)?"":' ');
        }
        System.out.println(ans);
    }
    
    
    public static void main(String[] args) throws Exception{
        new Round259_B().solve();
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer(in.readLine());

        }

        public String next() throws IOException {

            while (!st.hasMoreElements())
                st = new StringTokenizer(in.readLine());
            return st.nextToken();
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}