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.io.*;
import java.util.*;
import java.math.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
 
public class Main {
      
    int mod = 1000000007;

    public class SegmentTree{

       int n;
       int[] tree;

       SegmentTree(int[] arr){

          this.n = arr.length; 
          this.tree = new int[2 * n];

          for(int i = n; i < 2 * n; i++){
              this.tree[i] = arr[i - n];
          }

          for(int i = n - 1; i >= 1; i--){
              this.tree[i] = this.tree[2 * i] & this.tree[2 * i + 1];
          }

       }

       public int query(int l, int r){

          int res = (1 << 31) - 1;
          l = l + n;
          r = r + n;

          while(l < r){

              if(l % 2 == 1){
                  res &= tree[l]; 
                  l++;
              }

              if(r % 2 == 1){
                  r--;
                  res &= tree[r];
              }

              l /= 2;
              r /= 2;
          }

          return res;
       }
    }


    static int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59};
    
    public void solve() throws IOException{
         
       int n = in.nextInt();
       int[] aa = new int[n];
       for(int i = 0; i < n; i++){
         aa[i] = in.nextInt();
       }

       int[] fact = new int[60]; 
       for(int i = 2; i <= 59; i++){
         int key = 0, num = i, div = 0;
         while(num != 1){
            if(num % primes[div] == 0){
               num /= primes[div];
               key |= (1 << div);
            }else{
               div++;
            }
         }
         fact[i] = key;
       }

       int[][] path = new int[n + 1][1 << 17];
       int[][] dp = new int[n + 1][1 << 17];
       for(int i = 0; i <= n; i++){
           Arrays.fill(dp[i], 10000000);  
       }
       dp[0][0] = 0;
       int lastVal = 10000000;
       int lastPos = 0;
       int min = 100000;

       for(int i = 1; i <= n; i++){

          int ans = Integer.MAX_VALUE;

          for(int k = 1; k < 60; k++){
             
             int u = (~fact[k]) & ((1 << 17) - 1); 
             
             for(int s = u; ; s = (s - 1) & u){
               
                int error = Math.abs(aa[i - 1] - k);


                if(dp[i][s | fact[k]] > dp[i - 1][s] + error){

                   dp[i][s | fact[k]] = dp[i - 1][s] + error;
                   path[i][s | fact[k]] = k;

                   if(i == n && dp[i][s | fact[k]] < lastVal){
                        lastVal = dp[i][s | fact[k]];
                        lastPos = s | fact[k]; 
                   }
                }

                if(s == 0) break;
             }
          }
      }

      List<Integer> res = new ArrayList<>();
      int it = n;
      while(it != 0){
         int num = path[it][lastPos];
         res.add(num);
         lastPos -= fact[num];
         it--;
      }

      for(int i = res.size() - 1; i >= 0; i--){
         out.print(res.get(i) + " ");
      }

    }



    FastScanner in;
    PrintWriter out;
    
    static class FastScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
 
        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        String nextLine() throws IOException {
            if (st == null || !st.hasMoreTokens())
                return br.readLine();
            StringBuilder result = new StringBuilder(st.nextToken());
            while (st.hasMoreTokens()) {
                result.append(" ");
                result.append(st.nextToken());
            }
            return result.toString();
        }
 
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
 
    }
 
    void run() throws IOException {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }
 
    public static void main(String[] args) throws IOException{
        new Main().run();
    }
 
    public void printArr(int[] arr){
        for(int i = 0; i < arr.length; i++){
            out.print(arr[i] + " ");
        }
        out.println();
    }
 
    public long gcd(long a, long b){
        if(a == 0) return b;
        return gcd(b % a, a);
    }

    public boolean isPrime(long num){

        if(num == 0 || num == 1){
            return false;
        }

        for(int i = 2; i * i <= num; i++){
            if(num % i == 0){
                return false;
            }
        }

        return true;
    }

    public class Pair<A, B>{
        public A x; 
        public B y;

        Pair(A x, B y){
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair<?, ?> pair = (Pair<?, ?>) o;
            if (!x.equals(pair.x)) return false;
            return y.equals(pair.y);
        }

        @Override
        public int hashCode() {
            int result = x.hashCode();
            result = 31 * result + y.hashCode();
            return result;
        }

    }

    class Tuple{
        int x; int y; int z;
        Tuple(int ix, int iy, int iz){
            x = ix;
            y = iy;
            z = iz;
        }
    }
}
