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 = 1e9;
vector<int> primes(int n) {
  vector<int> p(n + 1, 1);
  for (int i = 2; i * i <= n; ++i)
    if (p[i])
      for (int j = i * i; j <= n; j += i) p[j] = 0;
  vector<int> res;
  for (int i = 2; i <= n; ++i)
    if (p[i]) res.push_back(i);
  return res;
}
int a[128], b[128];
int dp[128][1 << 16];
int pr[128][1 << 16];
int bit[64];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<int> prime = primes(54);
  for (int i = 0; i < (int)(128); i++)
    for (int j = 0; j < (int)(1 << 16); j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < (int)(64); i++)
    for (int j = 0; j < (int)(16); j++)
      if (i % prime[j] == 0) bit[i] += (1 << j);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(1 << 16); j++) {
      for (int k = 0; k < (int)(54); k++)
        if ((bit[k] & j) == 0)
          if (dp[i + 1][bit[k] | j] > dp[i][j] + abs(a[i] - k)) {
            dp[i + 1][bit[k] | j] = dp[i][j] + abs(a[i] - k);
            pr[i + 1][bit[k] | j] = k;
          }
    }
  int pos = 0;
  for (int i = 0; i < (int)(1 << 16); i++)
    if (dp[n][pos] > dp[n][i]) pos = i;
  vector<int> res;
  for (int i = n; i > 0; --i) {
    res.push_back(pr[i][pos]);
    int k = pr[i][pos];
    pos = pos - bit[k];
  }
  reverse((res).begin(), (res).end());
  for (int i = 0; i < (int)(res.size()); i++) {
    if (i > 0) cout << " ";
    cout << res[i];
  }
  cout << endl;
  return 0;
}