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 N = 61;
const int SZ = 106;
const int INF = 2E9;
int res = INF;
vector<int> prime;
int dp[SZ][(1LL << (17))];
int t[SZ][(1LL << (17))];
int a[SZ];
bool f[N];
long long c[N];
int n;
void sieve() {
  f[1] = f[0] = true;
  for (int i = 2; i * i < N; ++i)
    if (f[i] == false)
      for (int j = i * i; j < N; j += i) f[j] = true;
  for (int i = 1; i < N; ++i)
    if (f[i] == false) prime.push_back(i);
}
void factorize(int n) {
  for (int i = 0; i < (int)prime.size(); ++i) {
    int fact = prime[i];
    if (n % fact == 0) c[n] |= (1LL << (i));
  }
}
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sieve();
  for (int i = 1; i < N; ++i) factorize(i);
  for (int i = 0; i <= n; ++i)
    for (int mask = 0; mask < (1LL << (17)); ++mask) dp[i][mask] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int mask = 0; mask < (1LL << (17)); ++mask)
      for (int k = 1; k <= 60; ++k)
        if ((mask & c[k]) == 0)
          if (dp[i][mask | c[k]] > dp[i - 1][mask] + abs(a[i] - k)) {
            dp[i][mask | c[k]] = dp[i - 1][mask] + abs(a[i] - k);
            t[i][mask | c[k]] = k;
          }
  int ans_mask = 0;
  for (int mask = 0; mask < (1LL << (17)); ++mask)
    if (res > dp[n][mask]) {
      res = dp[n][mask];
      ans_mask = mask;
    }
  vector<int> ans;
  while (n >= 1) {
    int tmp = t[n][ans_mask];
    ans.push_back(tmp);
    --n;
    ans_mask = ans_mask ^ c[tmp];
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < (int)ans.size(); ++i) cout << ans[i] << " ";
}