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.util.*;

import static java.lang.Integer.MAX_VALUE;
import static java.lang.Math.abs;
import static java.lang.System.out;
import static java.util.stream.Collectors.joining;

/**
 * 453B
 *
 * @author artyom
 */
public class LittlePonyAndHarmonyChest {
    private static final short[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
    private static final int[] fact = new int[60]; // Prime factor sets

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

    private void solve() {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = in.nextInt();
        }
        int[][] dp = new int[n + 1][1 << 17]; // dp[i][j] = c, where i is an index of the element in arr, j is a prime factor bit mask
        // and c is the cost of modifying the original value of arr[i] into recover[i][j] (added up with the cost of previous modifications), which stores the new value
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < 1 << 17; j++) {
                dp[i][j] = MAX_VALUE;
            }
        }
        int[][] recover = new int[n + 1][1 << 17];
        // SOLUTION BEGINS
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < 60; j++) {
                for (int x = ~fact[j] & ((1 << 17) - 1), s = x; ; s = (s - 1) & x) {
                    int m = s | fact[j];
                    if (dp[i - 1][s] + abs(arr[i] - j) < dp[i][m]) {
                        dp[i][m] = dp[i - 1][s] + abs(arr[i] - j);
                        recover[i][m] = j;
                    }
                    if (s == 0) {
                        break;
                    }
                }
            }
        }
        // SOLUTION ENDS

        int minCost = MAX_VALUE, mask = -1;
        for (int j = 0; j < 1 << 17; j++) {
            if (minCost > dp[n][j]) {
                minCost = dp[n][j];
                mask = j;
            }
        }
        Deque<Integer> ans = new ArrayDeque<>(n);
        for (int i = n; i > 0; i--) {
            ans.push(recover[i][mask]);
            mask -= fact[recover[i][mask]];
        }
        out.print(ans.stream().map(Object::toString).collect(joining(" ")));
    }

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