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>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int maxn = 1e2 + 5;
const int nprime = 17;
const int state = (1 << 17) - 1;
int n, x, y;
vector<int> prime = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                     29, 31, 37, 41, 43, 47, 53, 59};
int id[maxn], a[maxn];
pair<int, pair<int, int> > dp[maxn][1 << nprime];
int bit[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("A"
            ".INP",
            "r")) {
    freopen(
        "A"
        ".INP",
        "r", stdin);
    freopen(
        "A"
        ".OUT",
        "w", stdout);
  }
  for (int i = 0; i < nprime; ++i) id[prime[i]] = i;
  cin >> n;
  fill_n(&dp[0][0], maxn * (1 << nprime), make_pair(1e9, make_pair(0, 0)));
  dp[0][0].first = 0;
  for (int j = 1; j <= 60; ++j) {
    for (int t = 0; t < nprime; ++t) {
      if (j % prime[t] == 0) {
        bit[j] |= (1 << t);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 1; j <= 60; ++j) {
      dp[i][bit[j]] =
          min(dp[i][bit[j]],
              make_pair(dp[i - 1][0].first + abs(a[i] - j), make_pair(0, j)));
      for (int t = (state ^ bit[j]); t > 0; t = (t - 1) & (state ^ bit[j])) {
        dp[i][bit[j] | t] =
            min(dp[i][bit[j] | t],
                make_pair(dp[i - 1][t].first + abs(a[i] - j), make_pair(t, j)));
      }
    }
  }
  auto it = min_element(dp[n], dp[n] + (1 << 17)) - dp[n];
  for (int i = n; i >= 0; --i) {
    a[i] = dp[i][it].second.second;
    it = dp[i][it].second.first;
  }
  for (int i = 1; i <= n; ++i) cout << a[i] << " ";
}