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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class B {    
    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

    int INF = Integer.MAX_VALUE/2;
    int MAX = 60;
    public void solve() throws IOException {                
        int N = nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = nextInt();
        }
        int[] primes = getPrimeNumbers(MAX);
        int P = primes.length;
        int[] fact = new int[MAX];
        for (int i = 1; i < MAX; i++) {
            for (int j = 0; j < primes.length; j++) {
                if (i % primes[j] == 0) {
                    fact[i] |= (1 << j);
                }
            }
        }

        int[] dp = new int[1<<P];
        int[][] from = new int[N][1<<P];
        int[][] pick = new int[N][1<<P];
        Arrays.fill(dp, INF);
        dp[0] = 0;
        for (int i = 0; i < N; i++) {
            int[] old = dp;
            dp = new int[1<<P];
            Arrays.fill(dp, INF);

            for (int k = 1; k < MAX; k++) {
                int s = (~fact[k]) & ((1 << P) - 1);

                for (int j = s; ; j = (j-1) & s) {
                    if (old[j] == INF) continue;
                    if (dp[j | fact[k]] > old[j] + Math.abs(k - A[i])) {
                        dp[j | fact[k]] = old[j] + Math.abs(k - A[i]);
                        pick[i][j | fact[k]] = k;
                        from[i][j | fact[k]] = j;
                    }
                    if (j == 0) break;
                }
            }
        }

        int best_v = INF;
        int best_start = -1;
        for (int i = 0; i < 1<<P; i++) {
            if (dp[i] < best_v) {
                best_v = dp[i];
                best_start = i;
            }
        }

        int[] ans = new int[N];
        int cur = best_start;
        for (int i = N-1; i >= 0; i--) {
            ans[i] = pick[i][cur];
            cur = from[i][cur];
        }

        for (int i = 0; i < N; i++) {
            out.print(ans[i] + " ");
        }
        out.println();
    }

    public int[] getPrimeNumbers(int max){
        boolean[] table = getPrimeTable(max);
        int size = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]) size++;
        }
        int[] rets = new int[size];
        int current = 0;
        for(int i = 1; i <= max; i++){
            if(table[i]){
                rets[current++] = i;
            }
        }
        return rets;
    }
    public boolean[] getPrimeTable(int max){
        boolean[] isPrime = new boolean[max+1];
        for(int i = 2; i <= max; i++){
            isPrime[i] = true;
        }
        for(int i = 2; i <= max; i++){
            if(isPrime[i]){
                for(int j = i+i; j <= max; j+=i){
                    isPrime[j] = false;
                }
            }
        }
        return isPrime;
    }
    
    /**
     * @param args
     */
    public static void main(String[] args) {
        new B().run();
    }
    
    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            out = new PrintWriter(System.out);
            solve();
            reader.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

}
