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.Collections;
import java.util.HashMap;
import java.util.HashSet;

/**
 * Created by Tejas on 19-10-2018.
 */
public class  Main{

    static int a[];
    static int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
    static int bitmasks[]=new int[59];
    public static void main(String[]args)throws IOException{
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        String temp[];
        int N=Integer.parseInt(bufferedReader.readLine());

        a=new int[N];

        temp=bufferedReader.readLine().split(" ");
        for(int i=0;i<N;i++)
            a[i]=Integer.parseInt(temp[i]);

        solve2(N);
    }

    private static void solve2(int N){
        getBitmasks();


        // dp[i][primesUsedSet] = dp[i-1][prevPrimesSet]+ k
        int dp[][]=new int[N+1][(1<<17)];
        int[][] parent=new int[N+1][(1<<17)];
        for (int i = 0; i < N; i++)
            Arrays.fill(dp[i],Integer.MAX_VALUE/2);

        int MAX=Integer.MAX_VALUE/2;
      /*  for (int i = 1; i < 60; i++) {
            dp[0][i]=Math.abs(a[0]-i);
        }*/
        for(int i=N-1;i>=0;i--) {
            for (int mask = 0; mask < (1 << 17); mask++) {
                dp[i][mask]=MAX;
                for(int k=1;k<59;k++){
                    if((mask & bitmasks[k])==0){
                        int xx=Math.abs(a[i]-k)+ dp[i+1][mask | bitmasks[k]];
                        if(xx< dp[i][mask]){
                            dp[i][mask]=xx;
                            parent[i][mask]=k;
                        }
                    }
                }
            }
        }
        int mask = 0;
        //StringBuilder sb=new StringBuilder();
        for(int i=0;i<N;i++){
            System.out.print(parent[i][mask] + " ");
            mask = mask | bitmasks[parent[i][mask]];
        }
        //System.out.println(sb.toString());
         /*   for(int k=1;k<60;k++) {
                int x=(~bitmasks[k]) & ((1<<17)-1);
                for(int s=x;s>0;s=(s-1) & x)
                    dp[i][s | bitmasks[k]]=Math.min(dp[i][s | bitmasks[k]],
                                                    dp[i-1][s]+Math.abs(a[i]-k));
            }
        }*/

    }

    public static void getBitmasks() {
        for(int i=1;i<60;i++){
            for(int pIndex=0;pIndex<primes.length;pIndex++){
                int prime=primes[pIndex];
                if(i%prime==0)
                    bitmasks[i]=(bitmasks[i] | (1<<pIndex));
            }
        }
    }
}