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 INF = 1 << 25;
vector<int> calc_primes(int maxn, int &sz) {
  vector<int> primes;
  primes.push_back(2);
  for (int(n) = (3); (n) < (maxn); (n)++) {
    bool isprime = true;
    for (int(i) = (0); (i) < (primes.size()); (i)++) {
      int p = primes[i];
      if (p * p > n) break;
      if (n % p == 0) {
        isprime = false;
        break;
      }
    }
    if (isprime) primes.push_back(n);
  }
  vector<int> mask(maxn, 0);
  sz = primes.size();
  for (int(n) = (1); (n) < (maxn); (n)++) {
    for (int(i) = (0); (i) < (primes.size()); (i)++)
      if (n % primes[i] == 0) mask[n] |= 1 << i;
  }
  return mask;
}
int dp[105][1 << 18], route[105][1 << 18];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int(i) = (0); (i) < (n); (i)++) {
    int x;
    cin >> x;
    v[i] = make_pair(x, i);
  }
  sort(v.begin(), v.end());
  int maxn = 60;
  int sz;
  vector<int> M = calc_primes(maxn, sz);
  for (int(i) = (0); (i) < (n + 1); (i)++)
    for (int(j) = (0); (j) < (1 << sz); (j)++) dp[i][j] = INF;
  dp[0][0] = 0;
  route[0][0] = 2;
  for (int(i) = (0); (i) < (n); (i)++)
    for (int(mask) = (0); (mask) < (1 << sz); (mask)++)
      if (dp[i][mask] != INF) {
        {
          int num = 1;
          if (dp[i + 1][mask | M[num]] >= dp[i][mask] + abs(v[i].first - num)) {
            dp[i + 1][mask | M[num]] = dp[i][mask] + abs(v[i].first - num);
            route[i + 1][mask | M[num]] = num;
          }
        }
        for (int(num) = (route[i][mask] + 1); (num) < (maxn); (num)++)
          if ((mask & M[num]) == 0) {
            if (dp[i + 1][mask | M[num]] >=
                dp[i][mask] + abs(v[i].first - num)) {
              dp[i + 1][mask | M[num]] = dp[i][mask] + abs(v[i].first - num);
              route[i + 1][mask | M[num]] = num;
            }
          }
      }
  vector<int> ans(n);
  int x = 0;
  for (int(i) = (0); (i) < (1 << sz); (i)++)
    if (dp[n][x] > dp[n][i]) x = i;
  for (int(i) = (n + 1) - 1; (i) >= (1); (i)--) {
    int cur = route[i][x];
    x = x ^ M[cur];
    int index = v[i - 1].second;
    ans[index] = cur;
  }
  bool first = true;
  for (int(i) = (0); (i) < (ans.size()); (i)++) {
    if (first)
      first = false;
    else
      cout << " ";
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}