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:
/*
    https://codeforces.com/blog/entry/13190?#comment-180828
        +
    Editorial
 */

//created by Whiplash99
import java.io.*;
import java.util.*;
public class D
{
    private static final int INF=(int) 1e8;
    private static int[] pos, fact;

    private static void assignPos()
    {
        int cur=0,i;
        for(i=2;i<60;i++)
        {
            int count=0;
            for(int j=1;j<=i;j++) if(i%j==0) count++;
            if(count==2) pos[i]=cur++;
        }
    }
    private static int getMask(int N)
    {
        int cur=2, mask=0;
        while (cur*cur<=N)
        {
            if(N%cur==0)
            {
                while (N%cur==0) N/=cur;
                mask|=1<<pos[cur];
            }
            cur++;
        }
        if(N>1) mask|=1<<pos[N];

        return mask;
    }
    private static void precomp()
    {
        pos=new int[60]; fact=new int[60];
        assignPos();

        for(int i=1;i<60;i++) fact[i]=getMask(i);
    }
    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        precomp();

        N=Integer.parseInt(br.readLine().trim());
        String[] s=br.readLine().trim().split(" ");
        int[] a=new int[N+1];
        for(i=0;i<N;i++) a[i+1]=Integer.parseInt(s[i]);

        int[][] dp=new int[N+1][1<<16];
        int[][] ans=new int[N+1][1<<16];
        int[][] prev=new int[N+1][1<<16];

        for(i=1;i<=N;i++) Arrays.fill(dp[i],INF);

        for(i=1;i<=N;i++)
        {
            for(int j=1;j<59;j++)
            {
                int x=(~fact[j])&((1<<16)-1);
                for(int sMask=x;;sMask=(sMask-1)&x)
                {
                    int tmp=dp[i-1][sMask]+Math.abs(a[i]-j);
                    if(tmp<dp[i][sMask|fact[j]])
                    {
                        dp[i][sMask|fact[j]]=tmp;
                        ans[i][sMask|fact[j]]=j;
                        prev[i][sMask|fact[j]]=sMask;
                    }

                    if(sMask==0) break;
                }
            }
        }

        int pos=-1, min=INF;
        for(i=0;i<dp[0].length;i++)
        {
            if(dp[N][i]<min)
            {
                min=dp[N][i];
                pos=i;
            }
        }

        ArrayList<Integer> list=new ArrayList<>();
        for(i=N;i>0;i--)
        {
            list.add(ans[i][pos]);
            pos=prev[i][pos];
        }

        Collections.reverse(list);
        StringBuilder sb=new StringBuilder();

        for(int z:list) sb.append(z).append(" ");
        System.out.println(sb);
    }
}