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;
const long long BIG_INF = 1e18;
const long long MOD = 1e9 + 7;
const int maxn = 1e2 + 5, maxval = 60, maxmask = (1 << 17);
int dp[maxn][maxmask], p[maxn][maxmask], b[maxn][maxmask];
int n, a[maxn], prime_mask[maxval], ans[maxn];
vector<int> primes;
bool is_prime[maxval];
void upd(int i, int mask, int val, int p_mask, int x) {
  if (val < dp[i][mask]) {
    dp[i][mask] = val;
    p[i][mask] = p_mask;
    b[i][mask] = x;
  }
}
void inc() {
  for (int i = 0; i < maxval; i++) is_prime[i] = true;
  for (int i = 2; i < maxval; i++) {
    if (!is_prime[i]) continue;
    primes.push_back(i);
    for (int j = i * i; j < maxval; j += i) is_prime[j] = false;
  }
  for (int i = 1; i < maxval; i++) {
    for (int j = 0; j < (int)primes.size(); j++)
      if (i % primes[j] == 0) prime_mask[i] |= (1 << j);
  }
  for (int i = 0; i <= n; i++) {
    for (int mask = 0; mask < maxmask; mask++) {
      dp[i][mask] = INF;
      p[i][mask] = -1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  inc();
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int x = 1; x < maxval; x++) {
      int mask = maxmask - 1;
      mask ^= prime_mask[x];
      for (int submask = mask;; submask = mask & (submask - 1)) {
        upd(i + 1, (submask | prime_mask[x]), dp[i][submask] + abs(a[i] - x),
            submask, x);
        if (!submask) break;
      }
    }
  }
  int cur_mask = -1;
  for (int mask = 0; mask < maxmask; mask++)
    if (cur_mask == -1 || dp[n][mask] < dp[n][cur_mask]) cur_mask = mask;
  for (int i = n; i > 0; i--) {
    ans[i - 1] = b[i][cur_mask];
    cur_mask = p[i][cur_mask];
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}