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.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Vector;
import java.io.OutputStream;
import java.util.Stack;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Bat-Orgil
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    static int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59};
    static int[] maskOf;
    static int[] a;
    static int[][] dp;
    static boolean[][] was;
    static int best[][];


    public static int dp(int n, int mask){
        if( n==0){
            return 0;
        }
        if(was[n][mask]){
            return dp[n][mask];
        }
        was[n][mask]=true;
        int answer= Integer.MAX_VALUE;
        for(int b=1; b<60; b++) {
            int m = maskOf[b];
            if( (mask & m) == m){
                if(answer>dp(n-1, (mask^m))+ Math.abs(b-a[n-1])){
                    answer= dp(n-1, (mask^m))+ Math.abs(b-a[n-1]);
                    best[n][mask]=b;
                }
            }
        }
        dp[n][mask]=answer;
        return answer;
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        maskOf= new int[60];
        for(int i=1; i<60; i++){
            int s= 0;
            for(int j=0; j<17; j++){
                if( i% primes[j] == 0){
                    s |= (1<<j);
                }
            }
            maskOf[i]=s;
           }

        int n= in.nextInt();
        a= new int[n];
        for(int i=0; i<n; i++){
            a[i]= in.nextInt();
        }

        dp= new int[n+1][(1<<17)];
        was= new boolean[n+1][1<<17];
        best= new int[n+1][1<<17];

        int ll= (1<<17)-1;
        dp(n, ll);

        int mask = (1<<17)-1;
        Stack<Integer> st= new Stack();
        for(int i=n; i>=1; i--){
            st.push(best[i][mask]);
            mask= mask ^ maskOf[best[i][mask]];
        }
        while(!st.isEmpty()){
            out.print(st.pop() + " ");
        }

    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}