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 MAX = 1e2 + 7;
int n;
int a[MAX];
int dp[MAX][(1 << 17)];
pair<int, int> Prev[MAX][(1 << 17)];
vector<int> p, b;
int mask[MAX];
void gen() {
  for (int i = 2; i <= 60; i++) {
    bool flag = true;
    for (int j = 2; j * j <= i; j++)
      if (i % j == 0) flag = false;
    if (flag) p.push_back(i);
  }
  for (int i = 2; i <= 60; i++) {
    int num = 0;
    for (int j = 0; j < p.size(); j++)
      if (i % p[j] == 0) num = num | (1 << j);
    mask[i] = num;
  }
}
void func() {
  int maxi = *max_element(a + 1, a + 1 + n);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < (1 << 17); j++) dp[i][j] = 1000000000;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < 2 * maxi; j++) {
      int msk = mask[j];
      msk = msk ^ ((1 << 17) - 1);
      for (int k = msk; k > 0; k = (k - 1) & msk) {
        if (dp[i][k | mask[j]] > dp[i - 1][k] + abs(j - a[i])) {
          dp[i][k | mask[j]] = dp[i - 1][k] + abs(j - a[i]);
          Prev[i][k | mask[j]] = make_pair(j, k);
        }
      }
      if (dp[i][mask[j]] > dp[i - 1][0] + abs(j - a[i])) {
        dp[i][mask[j]] = dp[i - 1][0] + abs(j - a[i]);
        Prev[i][mask[j]] = make_pair(j, 0);
      }
    }
  }
  int ans = 1000000000, msk = 0;
  for (int i = 0; i < (1 << 17); i++)
    if (dp[n][i] < ans) {
      ans = dp[n][i];
      msk = i;
    }
  assert(ans != 1000000000);
  int len = n;
  while (len > 0) {
    pair<int, int> p = Prev[len][msk];
    b.push_back(p.first);
    msk = p.second;
    len--;
  }
  reverse(b.begin(), b.end());
  for (auto j : b) cout << j << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  gen();
  func();
  return 0;
}