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:
//Author : QCC

import java.util.*;
import java.io.*;

/*------------------------------------*/

public class CF453B {

    public int n;
    public int a[];
    public int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
    public int f[][] = new int[111][1<<16];
    public int trace[][] = new int[111][1<<16];
    public int value[][] = new int[111][1<<16];
    public int bit[] = new int[66];

    int getBit(int x) {
        int r = 0;
        for(int i = 0; i < 16; i++) 
            if (x%prime[i] == 0)
                r |= 1<<i;
        return r;
    }

    public void solve() {
        n = in.nextInt();
        a = new int[n+10];
        for(int i = 1; i <= n; ++i)
            a[i] = in.nextInt();
        for (int i = 1; i <= 60; ++i ) 
            bit[i] = getBit(i);
        for(int i = 1; i <= n; ++i)
        for(int b = 0; b < 1 << 16; ++b)
            f[i][b] = 100000000;
        for(int i = 1; i <= n; ++i)
            for(int b = 0; b < 1 << 16; ++b)
            for(int v = 1; v <= 60; ++v)
                if ((bit[v]&b) == 0) {
                    int newB = bit[v]|b;
                    if (f[i-1][b] + Math.abs(v-a[i]) < f[i][newB]) {
                        f[i][newB] = f[i-1][b] + Math.abs(v-a[i]);
                        trace[i][newB] = b;
                        value[i][newB] = v;
                    }
                }
        int res = 100000000;
        int index = 0;
        for(int b = 0; b < 1<<16; ++b)
            if (f[n][b] < res) {
                res = f[n][b];
                index = b;
            }
        int b[] = new int[111];
        for(int i = n; i >= 1; --i) {
            b[i] = value[i][index];
            index = trace[i][index];
        }
        for (int i = 1; i <= n ; ++i) {
            out.print(b[i] + " " );
        }

            
    }

    public static void main (String[] args) throws java.lang.Exception {        
        long startTime = System.currentTimeMillis();

        out = new PrintWriter(System.out);
        new CF453B().solve();   
        //out.println((String.format("%.2f",(double)(System.currentTimeMillis()-startTime)/1000)));
        out.close();
    }

    static PrintWriter out;
    static class in {
        static BufferedReader reader = new BufferedReader( new InputStreamReader(System.in) ) ;
        static StringTokenizer tokenizer = new StringTokenizer("");             
        static String next() {      
            while ( !tokenizer.hasMoreTokens() )
                try { tokenizer = new StringTokenizer( reader.readLine() ); }
                catch (IOException e){
                    throw new RuntimeException(e);          
                }       
            return tokenizer.nextToken();
        }
        static int nextInt() { return Integer.parseInt( next() ); }         
    }
}