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;
const int MAXN = 105;
const int MAXV = 60;
const int MAXB = 17;
int n, ar[MAXN], dp[MAXN][1 << MAXB], par[MAXN][1 << MAXB], ans[MAXN];
int primes[MAXB], ind[MAXV], cnt;
vector<int> fact[MAXV];
vector<int> good[1 << MAXB], aft[1 << MAXB];
void init() {
  for (int i = 2; i < MAXV; i++)
    if (fact[i].empty()) {
      primes[cnt] = i, ind[i] = cnt, cnt++;
      for (int j = i; j < MAXV; j += i) fact[j].push_back(i);
    }
  for (int i = 0, _i = (1 << MAXB); i < _i; ++i) {
    for (int j = 1; j < MAXV; j++) {
      bool b = 1;
      int x = i;
      for (int k = 0, _k = (fact[j].size()); k < _k; ++k)
        if (i & 1 << ind[fact[j][k]]) {
          b = 0;
          break;
        } else
          x ^= 1 << ind[fact[j][k]];
      if (b) {
        good[i].push_back(j);
        aft[i].push_back(x);
      }
    }
  }
}
int calc(int a, int b) {
  if (a == 0) return 0;
  int& ret = dp[a][b];
  if (ret != -1) return ret;
  ret = 1e9;
  for (int i = 0, _i = (good[b].size()); i < _i; ++i) {
    int res = abs(ar[a - 1] - good[b][i]) + calc(a - 1, aft[b][i]);
    if (res < ret) ret = res, par[a][b] = i;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
  cin >> n;
  for (int i = 0, _i = (n); i < _i; ++i) cin >> ar[i];
  init();
  memset(dp, -1, sizeof(dp));
  calc(n, 0);
  int a = n, b = 0;
  while (a) {
    int i = par[a][b];
    ans[a - 1] = good[b][i];
    a--, b = aft[b][i];
  }
  for (int i = 0, _i = (n); i < _i; ++i) cout << ans[i] << ' ';
  return 0;
}