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;
using ll = long long;
using pll = pair<ll, ll>;
using dd = long double;
namespace {
static bool constexpr dbg = 0;
ll constexpr p[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53},
             np = 16;
ll constexpr N = 110, S = 1 << (np + 1);
int constexpr INF = INT32_MAX / 4;
ll n;
int a[N], d[N][S], prev[N][S], num[N][S], fac[60];
void init() {
  cin >> n;
  for (ll i = 1; i <= (ll)(n); ++i) cin >> a[i];
}
void dump(ll idx, ll st) {
  if (!idx) return;
  dump(idx - 1, prev[idx][st]);
  cout << num[idx][st] << ' ';
}
void solve() {
  for (ll i = 0; i < (ll)(60); ++i)
    for (ll j = 0; j < (ll)(np); ++j)
      if (i % p[j] == 0) fac[i] |= (1 << j);
  for (ll i = 1; i <= (ll)(n); ++i) {
    for (ll j = 0; j < (ll)(S); ++j) d[i][j] = INF;
    for (ll j = 1; j <= (ll)(59); ++j) {
      ll x = (~fac[j]) & ((1 << np) - 1);
      for (ll pr = x;; pr = (pr - 1) & x) {
        ll cur = pr | fac[j];
        if (d[i - 1][pr] + abs(a[i] - j) < d[i][cur]) {
          d[i][cur] = d[i - 1][pr] + abs(a[i] - j);
          prev[i][cur] = pr;
          num[i][cur] = j;
        }
        if (!pr) break;
      }
    }
  }
  ll v = INF, st = 0;
  for (ll j = 0; j < (ll)(S); ++j)
    if (d[n][j] < v) {
      v = d[n][j];
      st = j;
    }
  dump(n, st);
}
}  // namespace
int main() {
  if (!dbg) {
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  cout << fixed << setprecision(20);
  init();
  solve();
  return 0;
}