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.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class R259D1B {
    static final int INF = (int)1e9;
    static final int BOUND = 60;
    static Integer[] genPrimes(int n){
        ArrayList<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        for(int i=3; i<n; i++){
            boolean isPrime = true;
            for(int j=0; j<primes.size(); j++){
                if(i%primes.get(j)==0) isPrime=false;
            }
            if(isPrime) primes.add(i);
        }
        return primes.toArray(new Integer[0]);
    }
    static int getBitMask(int n, Integer[] primes){
        int ret=0;
        for(int i=0; i<primes.length; i++){
            if(n%primes[i]==0) ret+=(1<<i);
        }
        return ret;
    }
    static class Data implements Comparable<Data>{
        int index, value;

        Data(int index, int value) {
            this.index = index;
            this.value = value;
        }
        @Override
        public int compareTo(Data o) {
            return o.value-this.value;
        }
    }
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        Data[] a = new Data[n];
        for(int i=0; i<n; i++){
            a[i] = new Data(i, Integer.parseInt(st.nextToken()));
        }
        Arrays.sort(a);
        Integer[] primes = genPrimes(BOUND);
        int m = primes.length;
        int k = Math.min(n,m);
        int[] bitMasks = new int[BOUND];
        for(int i=2; i<BOUND; i++){
            bitMasks[i] = getBitMask(i, primes);
        }
        int[][] dp = new int[k+1][1<<m];
        int[][] tracking = new int[k+1][1<<m];
        int[][] trace = new int[k+1][1<<m];
        for(int i=0; i<=k; i++){
            for(int j=0; j<(1<<m); j++) dp[i][j]=INF;
        }
        dp[0][0]=0;
        for(int i=0; i<k; i++){
            for(int j=0; j<(1<<m); j++){
                if(dp[i][j]!=INF){
                    dp[i+1][j] = dp[i][j]+Math.abs(a[i].value-1);
                    tracking[i+1][j] = j;
                    trace[i+1][j] = 1;
                }
                    for(int candidate=2; candidate<BOUND; candidate++){
                        int bitMask = bitMasks[candidate];
                        if((j&bitMask)==bitMask){
                            if(dp[i+1][j]>dp[i][j-bitMask]+Math.abs(a[i].value-candidate)){
                                dp[i+1][j] = dp[i][j-bitMask]+Math.abs(a[i].value-candidate);
                                tracking[i+1][j] = j-bitMask;
                                trace[i+1][j] = candidate;
                            }
                        }
                    }
            }
        }
        int min = INF;
        int j=0;
        for(int i=0; i<(1<<m); i++){
            if(min>dp[k][i]){
                min=dp[k][i];
                j=i;
            }
        }
        int[] result = new int[n];
        Arrays.fill(result, 1);
        for(int i=k-1; i>=0; i--){
            result[a[i].index] = trace[i+1][j];
            j = tracking[i+1][j];
        }
        min = 0;
        for(int i=0; i<n; i++){
            min+=Math.abs(a[i].value-result[a[i].index]);
            if(i==n-1) System.out.println(result[i]); else System.out.print(result[i]+" ");
        }
//        System.out.println(min);
    }
}