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 
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.lang.System.*;
public class dp0
{
    public static void main(String[]args){
        InputReader sc = new InputReader(System.in);
        PrintWriter pw =new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n=sc.nextInt();
        int[]arr=sc.nextIntArray(n);
        int[]factors=new int[61];//1 to 60
        int[]primeid=new int[61];//id of each of the 17 primes
        primeid[2]=0;
        primeid[3]=1;
        primeid[5]=2;
        primeid[7]=3;
        primeid[11]=4;
        primeid[13]=5;
        primeid[17]=6;
        primeid[19]=7;
        primeid[23]=8;
        primeid[29]=9;
        primeid[31]=10;
        primeid[37]=11;
        primeid[41]=12;
        primeid[43]=13;
        primeid[47]=14;
        primeid[53]=15;
        primeid[59]=16;
        for(int i=2;i<61;i++){
            int cur=i;
            for(int a=2;a<i+1;a++){
                if(cur%a==0){
                    while(cur%a==0)
                    cur/=a;
                    if((factors[i]&(1<<primeid[a]))==0)
                    factors[i]+=(1<<primeid[a]);
                }
            }
        }
        int[][]dp=new int[n+1][1<<17];
        for(int i=0;i<dp.length;i++){
            Arrays.fill(dp[i],999999);
        }
        dp[0][0]=0;
        int[][]nexts=new int[1<<17][65];
        for(int i=0;i<nexts.length;i++){
            int ite=1;
            for(int a=0;a<61;a++){
                if((i&factors[a])==0){
                    nexts[i][ite++]=a;
                }
            }
            nexts[i][0]=ite-1;
        }
        
        int[][]backtrack=new int[n+1][1<<17];
        int[][]backtrackid=new int[n+1][1<<17];
        for(int i=0;i<dp.length-1;i++){
            for(int a=0;a<dp[i].length;a++){
                for(int c=0;c<nexts[a][0];c++){
                    int b=nexts[a][c+1];
                    if((a&factors[b])==0){
                        if(dp[i+1][a|factors[b]]>Math.abs(arr[i]-b)+dp[i][a]){
                            dp[i+1][a|factors[b]]=Math.abs(arr[i]-b)+dp[i][a];
                            backtrack[i+1][a|factors[b]]=a;
                            backtrackid[i+1][a|factors[b]]=b;
                        }
                    }
                }
                
            }
            
        }
        int[]after=new int[n];
        int ite=0;
        for(int i=0;i<(1<<17);i++){
            if(dp[n][i]<dp[n][ite])ite=i;
        }
        
        for(int i=after.length-1;i>-1;i--){
            after[i]=backtrackid[i+1][ite];
            ite=backtrack[i+1][ite];
        }
        for(int i=0;i<after.length-1;i++){
            System.out.print(after[i]+" ");
        }
        System.out.println(after[after.length-1]);
        
        pw.flush();
    }
    
    static class InputReader
    {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;
        public InputReader(InputStream stream)
        {
                this.stream = stream;
        }
        public int snext()
        {
                if (snumChars == -1)
                        throw new InputMismatchException();
                if (curChar >= snumChars)
                {
                        curChar = 0;
                        try
                        {
                                snumChars = stream.read(buf);
                        } catch (IOException e)
                        {
                                throw new InputMismatchException();
                        }
                        if (snumChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }
        public int nextInt()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                int res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }
        public long nextLong()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                long res = 0;
                do
                {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = snext();
                } while (!isSpaceChar(c));
                return res * sgn;
        }
        public double nextDouble()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                int sgn = 1;
                if (c == '-')
                {
                        sgn = -1;
                        c = snext();
                }
                double res = 0;
                while(c<='9'&&c>='0'){
                    res*=10;
                    res+=c-'0';
                    c=snext();
                }
                if(c=='.'){
                    double decimal=0;
                    long multiplier=1;
                    c=snext();
                    do
                    {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        decimal *= 10;
                        decimal += c - '0';
                        multiplier*=10;
                        c = snext();
                    } while (!isSpaceChar(c));
                    return sgn*(res+decimal/multiplier);
                }else{
                    if(!isSpaceChar(c)){
                        throw new InputMismatchException();
                    }
                    return sgn*res;
                }
        }
        public int[] nextIntArray(int n)
        {
                int a[] = new int[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextInt();
                }
                return a;
        }
        public long[] nextLongArray(int n)
        {
                long a[] = new long[n];
                for (int i = 0; i < n; i++)
                {
                        a[i] = nextLong();
                }
                return a;
        }
        public String next(){return readString();}
        public String readString()
        {
                int c = snext();
                while (isSpaceChar(c))
                {
                        c = snext();
                }
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isSpaceChar(c));
                return res.toString();
        }
        public String nextLine()
        {
                int c = snext();
                StringBuilder res = new StringBuilder();
                do
                {
                        res.appendCodePoint(c);
                        c = snext();
                } while (!isEndOfLine(c));
                if(isEndOfLine(res.charAt(res.length()-1)))
                return res.deleteCharAt(res.length()).toString();
                return res.toString();
        }
        public ArrayList<String> readAll(){
            ArrayList<String>a=new ArrayList<String>();
            try{
                while(true){
                    a.add(nextLine());
                }
            }catch(Exception e){
                
            }
            return a;
        }
        public boolean hasNext(){
            boolean hasnext=true;
            try{
                hasnext= stream.available()!=0;
            }catch(IOException e){
            }
            return hasnext||curChar<snumChars;
        }
        public boolean isSpaceChar(int c)
        {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        private boolean isEndOfLine(int c)
        {
                return c == '\n' || c == '\r' || c == -1;
        }
        public interface SpaceCharFilter
        {
                public boolean isSpaceChar(int ch);
        }
    }
}