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:
//package round259div1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class B {

    public static void main(String[] args) throws IOException {
        taskB solver = new taskB();
        solver.read();
    }

}

class InputReader {
    private BufferedReader input;
    private StringTokenizer tokenizer;
    
    public InputReader ( InputStream stream ) {
        input = new BufferedReader ( new InputStreamReader ( stream ), 32768 );
        tokenizer = null;
    }
    
    public void close() throws IOException {
        try {
            input.close();
        }
        catch ( IOException error ) {
            throw new RuntimeException ( error );
        }
    }
    
    public String next () {
        while ( tokenizer == null || !tokenizer.hasMoreTokens() ) {
            try {
                tokenizer = new StringTokenizer ( input.readLine() );
            }
            catch ( IOException error ) {
                throw new RuntimeException ( error );
            }
        }
        return tokenizer.nextToken();
    }
    
    public int nextInt() {
        return Integer.parseInt( next() );
    }
    
    public double nextDouble() {
        return Double.parseDouble ( next() );
    }
    
    public long nextLongLong() {
        return Long.parseLong( next() );
    }
    
    public String nextString() {
        return next();
    }
    
    public boolean nextBool() {
        return Boolean.parseBoolean( next() );
    }
    
}


class taskB {
 
    final int INF = 1000000007;
    final int N = 102;
    private int n;
    private int[] a , pw;
    private ArrayList<Integer> p;
    private int[][] f , trace2;
    InputReader in;
    
    public taskB() {
        in = new InputReader(System.in);
    }
    
    public boolean isprime(int q) {
        for (int i = 2 ; i < q ; i++)
            if (q % i == 0) return false;
        return true;
    }
    
    public boolean match(int number , int s) {
        return ((pw[number] & s) == 0);
    }
    
    public void truy(int n , int s) {
        if (n == 0) return;
        truy(n - 1 , s - pw[trace2[n][s]]);
        System.out.print(trace2[n][s] + " ");
    }
    
    public void read() {
        n = in.nextInt();
        pw = new int[66];
        a = new int[n + 1];
        p = new ArrayList<Integer>();
        trace2 = new int[n + 1][1<<17];
        f = new int[n + 1][1<<17];
        
        for (int i = 1 ; i <= n ; i++)
            a[i] = in.nextInt();
        
        for (int i = 2 ; i < 60 ; i++)
            if (isprime(i)) p.add(i);
        
        for (int i = 2 ; i < 60 ; i++)
            for (int j = 0 ; j < (int)p.size() ; j++)
                if ((i % p.get(j)) == 0) 
                    pw[i] += (1 << j);
        
        for (int i = 0 ; i <= n ; i++)
            for (int j = 0 ; j < (1 << 16) ; j++)
                f[i][j] = INF;
        f[0][0] = 0;
        
        for (int i = 0 ; i < n ; i++)
            for (int s = 0 ; s < (1 << 16) ; s++) {
                
                if (f[i + 1][s] == INF || f[i + 1][s] > f[i][s] + Math.abs(1 - a[i + 1])){
                    trace2[i + 1][s] = 1;
                    f[i + 1][s] = f[i][s] + Math.abs(1 - a[i + 1]);
                }
                for (int number = 2 ; number < 59; number++){
                    if (match(number,s)) {
                        int nw = s + pw[number];
                        if (f[i][s] + Math.abs(a[i + 1] - number) < f[i + 1][nw]) {
                            f[i + 1][nw] = f[i][s] + Math.abs(a[i + 1] - number);
                            trace2[i + 1][nw] = number;
                        }
                    }
                }
            }
        
        int max = 0;
        for (int i = 1 ; i < (1 << 16) ; i++)
            if (f[n][i] < f[n][max]) max = i;
        
        truy(n , max);
    }
    
}