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.*;

public class B {
  static int[] primes = new int[]{
    2, 3, 5, 7, 11, 13, 17, 19, 23,
    29, 31, 37, 41, 43, 47, 53};
  static int MAX = 58;

  static int[] F = new int[MAX+1];

  static Integer[][] DP;
  static int[] A;
  public static int f(int used, int i) {
    if(i==A.length) { return 0; }
    if(DP[used][i]!=null) { return DP[used][i]; }
    int ans = 1000*1000;

    for(int x=1; x<=MAX; x++) {
      int f = F[x];
      if((used&f)>0) { continue; }
      ans = Math.min(ans, Math.abs(A[i]-x) + f(used|f, i+1));
    }
    return DP[used][i] = ans;
  }

  static int factors(int x) {
    int ans = 0;
    for(int i=0; i<primes.length; i++) {
      if(x%primes[i] == 0) {
        ans |= 1<<i;
      }
    }
    return ans;
  }

  public static void main(String[] args) {
    for(int x=1; x<=MAX; x++) {
      F[x] = factors(x);
    }

    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    A = new int[n];
    for(int i=0; i<n; i++) {
      A[i] = in.nextInt();
    }
    DP = new Integer[1<<primes.length][n];
    f(0, 0);

    int used = 0;

    int[] B = new int[n];
    for(int bi=0; bi<n; bi++) {
      for(int x=0; x<=MAX; x++) {
        int f = F[x];
        if((used&f) > 0) { continue; }
        int old_cost = f(used, bi);
        int new_cost = Math.abs(x-A[bi]) + f(used|f, bi+1);
        if(old_cost == new_cost) {
          B[bi] = x;
          used |= f;
          break;
        }
      }
    }
    for(int i=0; i<n; i++) {
      System.out.printf("%d%c", B[i], i==n-1?'\n':' ');
    }
  }
}