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.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.HashMap;
import java.io.BufferedReader;
import java.util.Map;
import java.io.PrintStream;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author shu_mj @ http://shu-mj.com
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    Scanner in;
    PrintWriter out;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
        run();
    }


    void run() {
        int n = in.nextInt();
        int[] is = in.nextIntArray(n);
        List<Integer> primes = new ArrayList<Integer>();
        boolean[] isPrime = Num.primeTable(60, primes);
        int[] mask = new int[61];
        int ps = primes.size();
        for (int i = 2; i <= 60; i++) {
            for (int j = 0; j < ps; j++) {
                if (i % primes.get(j) == 0) mask[i] |= 1 << j;
            }
        }
        int[][] dp = new int[n + 1][1 << ps];
        int[][] preJ = new int[n + 1][1 << ps];
        int[][] preSt = new int[n + 1][1 << ps];
        Algo.fill(dp, -1);
        Algo.fill(preJ, -1);
        Algo.fill(preSt, -1);
        dp[0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < 60; j++) {
                for (int k = 0; k < (1 << ps); k++) if (dp[i][k] != -1 && (k & mask[j]) == 0) {
                    if (dp[i + 1][k | mask[j]] == -1 || dp[i + 1][k | mask[j]] > dp[i][k] + Math.abs(j - is[i])) {
                        dp[i + 1][k | mask[j]] = dp[i][k] + Math.abs(j - is[i]);
                        preJ[i + 1][k | mask[j]] = j;
                        preSt[i + 1][k | mask[j]] = k;
                    }
                }
            }
        }
        int st = -1;
        for (int i = 0; i < (1 << ps); i++) if (dp[n][i] != -1 && (st == -1 || dp[n][i] < dp[n][st])) st = i;
        Algo.debug(dp[n][st]);
        print(dp, preJ, preSt, n, st);
        out.println();
    }

    private void print(int[][] dp, int[][] preJ, int[][] preSt, int i, int st) {
        if (i > 1) print(dp, preJ, preSt, i - 1, preSt[i][st]);
        out.print(preJ[i][st] + " ");
    }
}

class Scanner {
    BufferedReader br;
    StringTokenizer st;

    public Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null)
                return false;
            eat(s);
        }
        return true;
    }

    public String next() {
        hasNext();
        return st.nextToken();
    }

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

    public int[] nextIntArray(int n) {
        int[] is = new int[n];
        for (int i = 0; i < n; i++) {
            is[i] = nextInt();
        }
        return is;
    }

}

class Num {
    public static List<Integer> primes;
    public static boolean[] isPrime;

    public static boolean[] primeTable(int n, List<Integer> primes) {
        Num.primes = primes;
        isPrime = new boolean[n + 1];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        /*
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) primes.R(i);
            for (int p : primes) {
                if (i > n / p) break;
                isPrime[i * p] = false;
                if (i % p == 0) break;
            }
        }*/
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j <= n; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        return isPrime;
    }

}

class Algo {

    public static void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void fill(int[][] iss, int v) {
        for (int[] is : iss) Arrays.fill(is, v);
    }


}