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;
template <typename T, typename V>
inline void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << "}\n";
}
template <typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}\n";
}
const int N = 101, M = 60;
int n, A[N], id[M], res[N], dp[N][1 << 17], trace[N][1 << 17];
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
inline bool getbit(int x, int i) { return (x >> i) & 1; }
inline void clearbit(int &x, int i) { x &= (~(1 << i)); }
inline void setbit(int &x, int i) { x |= (1 << i); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0, _n = (17); i < _n; ++i) id[prime[i]] = i;
  int s, val;
  fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(int), 2e9);
  fill(dp[0], dp[0] + sizeof(dp[0]) / sizeof(int), 0);
  for (int i = 1, _n = (n); i <= _n; ++i) cin >> A[i];
  for (int i = 1, _n = (n); i <= _n; ++i) {
    for (int x = 1, _n = (M); x <= _n; ++x) {
      s = 0;
      val = x;
      for (int j = 2; j * j <= val; ++j) {
        while (val % j == 0) {
          val /= j;
          setbit(s, id[j]);
        }
      }
      if (val > 1) setbit(s, id[val]);
      for (int mask = 0, _n = (1 << 17); mask < _n; ++mask) {
        if ((s & mask) == s) {
          if (dp[i - 1][s ^ mask] + abs(A[i] - x) < dp[i][mask]) {
            dp[i][mask] = dp[i - 1][s ^ mask] + abs(A[i] - x);
            trace[i][mask] = x;
          }
        }
      }
    }
  }
  int msk = (1 << 17) - 1;
  for (int i = (n); i > 0; --i) {
    val = res[i] = trace[i][msk];
    s = 0;
    for (int j = 2; j * j <= val; ++j) {
      while (val % j == 0) {
        val /= j;
        setbit(s, id[j]);
      }
    }
    if (val > 1) setbit(s, id[val]);
    msk ^= s;
  }
  for (int i = 1, _n = (n); i <= _n; ++i) cout << res[i] << ' ';
  return 0;
}