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 codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class B {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

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

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

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

    void solve() throws IOException {
        final int n = nextInt();
        final int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        final int[] primes = new int[16];
        int px = 0;
        for(int i = 2; px < 16; i++) {
            if(isPrime(i)) {
                primes[px++] = i;
            }
        }
        class Solver {
            int[] primeMask = new int[59];

            {
                for(int i = 1; i < primeMask.length; i++) {
                    for(int j = 0; j < primes.length; j++) {
                        if(i % primes[j] == 0) {
                            primeMask[i] += 1 << j;
                        }
                    }
                }
            }

            int[][] nextMask = new int[n + 1][1 << primes.length];
            short[][] dp = new short[n + 1][1 << primes.length];
            byte[][] optNumber = new byte[n + 1][1 << primes.length];

            {
                for(int i = 0; i <= n; i++) {
                    Arrays.fill(dp[i], (short)-1);
                }
            }

            int solve(int k, int mask) {
                if(dp[k][mask] != -1) {
                    return dp[k][mask];
                }
                if(k == n) {
                    return dp[k][mask] = 0;
                }
                int ret = Integer.MAX_VALUE;
                for(int i = 1; i < primeMask.length; i++) {
                    if((mask & primeMask[i]) == 0) {
                        if(ret > Math.abs(a[k] - i) + solve(k + 1, mask | primeMask[i])) {
                            ret = Math.abs(a[k] - i) + solve(k + 1, mask | primeMask[i]);
                            optNumber[k][mask] = (byte)i;
                            nextMask[k][mask] = mask | primeMask[i];
                        }
                    }
                }
                return dp[k][mask] = (short)ret;
            }

            void print(int k, int mask) {
                if(k == n) {
                    return;
                }
                writer.print(optNumber[k][mask] + " ");
                print(k + 1, nextMask[k][mask]);
            }
        }
        Solver solver = new Solver();
        solver.solve(0, 0);
        solver.print(0, 0);
        writer.close();
    }

    private boolean isPrime(int i) {
        for(int j = 2; j * j <= i; j++) {
            if(i % j == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) throws IOException {
        new B().solve();
    }
}