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.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ExecutionException;

public class Main {



    public static void main(String args[]) throws IOException{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        //begin
        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[] fact = new int[61];
        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;
        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];
        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 = fact[nxt];
                for (int old = (maxMask - 1) & (~badMask);; old = (old - 1) & (~badMask)) {
                    int nmask = old | fact[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 &= ~fact[res[i]];
        }
        for (int i = 0; i < n; ++i) {
            if (i > 0) out.print(" ");
            out.print(res[i]);
        }
        out.println();
        //end
        out.close();

    }
}

class InputReader{
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next(){
        while(tokenizer == null || !tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            }catch(IOException e){
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

}