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.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in1
 * Actual solution is at the top
 * @author xiaodao
 */
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);
		B solver = new B();
		solver.solve(1, in, out);
		out.close();
	}
}

class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {

        int[] primes = new int[0];
        for (int i=2;i<=60;++i){
            boolean ok = true;
            for (int j=2;j<i;++j)if(i%j==0) ok = false;
            if (ok){
                primes = Arrays.copyOf(primes, primes.length+1);
                primes[primes.length-1] = i;
            }
        }

        int maxMask = 1 << primes.length;
        int []mask = new int[61];

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

        int n = in.nextInt();
        int[] a = new int[n]; for (int i=0;i<n;++i) a[i] = in.nextInt();
        int[] best = new int[maxMask];
        int[] nbest = new int[maxMask];
        int [][] via = new int[n][maxMask];

        /*out.print(maxMask);

        for (int i=0;i<n;++i){
            Arrays.fill(nbest, (int)1e9);
            for (int j=1;j<=60;++j){
                int badMask = mask[j];
                for (int old = (maxMask-1)&(~badMask);;old=(old-1)&(~badMask)){
                    int nmask = old | badMask;

                    int got = best[old] + Math.abs(a[i] - j);
                    if (got < nbest[nmask]){
                        nbest[nmask] = got;
                        via[i][nmask] = j;
                    }
                }
            }

            int[] tmp = best; best = nbest; nbest = tmp;
        }



        int[] b = new int[n];
        int s = maxMask - 1;
        for (int i=n-1;i>=0;--i){
            b[i] = via[i][s];
            s &=~ mask[b[i]];
        }


        for (int i=0;i<n;++i){
            if (i>0) out.print(" ");
            out.print(b[i]);
        }*/
        for (int i = 0; i < n; ++i) {
            Arrays.fill(nbest, (int) 1e9);
            int cur = a[i];
            for (int nxt = 1; nxt <= 60; ++nxt) {
                int badMask = mask[nxt];
                for (int old = (maxMask - 1) & (~badMask);; old = (old - 1) & (~badMask)) {
                    int nmask = old | mask[nxt];
                    int got = best[old] + Math.abs(nxt - cur);
                    if (got < nbest[nmask]) {
                        nbest[nmask] = got;
                        via[i][nmask] = nxt;
                    }
                    if (old == 0) break;
                }
            }
            int[] tmp = best;
            best = nbest;
            nbest = tmp;
        }
        int[] res = new int[n];
        int cmask = maxMask - 1;
        for (int i = n - 1; i >= 0; --i) {
            res[i] = via[i][cmask];
            cmask &= ~mask[res[i]];
        }
        for (int i = 0; i < n; ++i) {
            if (i > 0) out.print(" ");
            out.print(res[i]);
        }
        out.println();
    }
}