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.Arrays;
import java.util.Map;
import java.util.Scanner;

/**
 * Created by ali on 8/3/14.
 */
public class B
{
    private static final int [] primes = new int[] {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
    private static int [] a;
    private static final int oo = 2000000000;
    private static int n;
    private static int [][] nextUsed;

    public static void main(String [] args) {
        int [] mask = new int[60];
        for(int a = 1 ; a <= 58 ; a++)
            for(int i = 0 ; i < primes.length ; i++)
                if(a%primes[i] == 0)
                    mask[a] |= (1<<i);

        Scanner in = new Scanner(System.in);

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


        int [] cr = new int[1 << primes.length];
        int [] ne = new int[1 << primes.length];
        int[][] pr = new int[n + 1][1 << primes.length];

        Arrays.fill(cr, oo);
        for (int[] fill : pr)
            Arrays.fill(fill, -1);

        cr[0] = 0;

        for (int till = 0; till < n; till++)
        {
            Arrays.fill(ne, oo);

            for(int next = 1 ; next <= 58 ; next++)
            {
                int badMask = mask[next];

                for(int oldMask = (~badMask) & ((1<<primes.length)-1) ; ; oldMask = (oldMask-1)&(~badMask))
                {
                    int newMask = oldMask|badMask;
                    if(cr[oldMask] + Math.abs(a[till] - next) < ne[newMask])
                    {
                        ne[newMask] = cr[oldMask] + Math.abs(a[till] - next);
                        pr[till+1][newMask] = next;
                    }

                    if(oldMask == 0)
                        break;
                }
            }

            cr = ne.clone();
        }

        int min = oo;
        int lastUsed = -1;
        for (int used = 0; used < 1 << primes.length; used++)
            if (cr[used] < min) {
                min = cr[used];
                lastUsed = used;
            }

        int[] b = new int[n];
        int ct = n;
        int cu = lastUsed;

        while (pr[ct][cu] != -1) {
            b[ct - 1] = pr[ct][cu];
            cu ^= mask[pr[ct][cu]];
            ct--;
        }

        for (int i = 0; i < n - 1; i++)
            System.out.print(b[i] + " ");
        System.out.println(b[n - 1]);

    }
}