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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int a[1000002];
int isprime[100];
int dp[102][131080];
vector<int> prime;
int pow2[20];
int mapa[102][131080];
int main() {
  int x1 = 1;
  for (int i = 0; i <= 17; i++) {
    pow2[i] = x1;
    x1 *= 2;
  }
  for (int i = 2; i <= 60; i++) {
    if (!isprime[i]) {
      for (int j = 2 * i; j <= 60; j += i) {
        isprime[j] = 1;
      }
      prime.push_back(i);
    }
  }
  for (int i = 0; i <= 100; i++)
    for (int j = 0; j < 131075; j++) dp[i][j] = 60 * 1000;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int f = 0;
    for (int j = 1; j <= 60; j++) {
      f = 0;
      for (int x = 0; x < prime.size(); x++) {
        if (prime[x] > j) break;
        if (j % prime[x] == 0) f += pow2[x];
      }
      int t1 = 0;
      for (int z = 0; z < 131072; z++) {
        if ((z & f) == 0) {
          if (dp[i + 1][z | f] > (dp[i][z] + abs(a[i] - j))) {
            mapa[i + 1][z | f] = j;
            dp[i + 1][z | f] = dp[i][z] + abs(a[i] - j);
          }
        }
      }
    }
  }
  int val = INT_MAX, b1, gl, g2, g3;
  vector<int> a2;
  for (int i = n; i >= 1; i--) {
    if (i == n) {
      for (int j = 0; j < 131072; j++) {
        if (val > dp[i][j]) {
          val = dp[i][j];
          b1 = j;
        }
      }
      a[i] = (mapa[n][b1]);
      gl = mapa[n][b1];
      g3 = b1;
    } else {
      int f = 0;
      int j = gl;
      for (int x = 0; x < prime.size(); x++) {
        if (prime[x] > j) break;
        if (j % prime[x] == 0) f += pow2[x];
      }
      g2 = g3 ^ f;
      gl = mapa[i][g2];
      a[i] = gl;
      g3 = g2;
    }
  }
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}