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 = (long long)1e9;
const int mod = inf + 7;
const double pi = acos(-1.0);
int n;
int a[111];
vector<int> v;
int dp[111][(1 << 17) + 123], premask[60], p[111][(1 << 17) + 123];
bool prime(int x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= 60; ++i) {
    if (prime(i)) v.push_back(i);
  }
  for (int i = 1; i <= 60; ++i) {
    for (int j = 0; j < (int)v.size(); ++j) {
      if (i % v[j] == 0) premask[i] ^= (1 << j);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int mask = 0; mask < (1 << 17); ++mask) dp[i][mask] = inf;
  for (int i = 0; i < n; ++i) {
    for (int mask = 0; mask < (1 << 17); ++mask) {
      for (int x = 1; x <= 2 * a[i + 1]; ++x) {
        if ((mask & premask[x])) continue;
        int nmask = mask ^ premask[x];
        if (dp[i + 1][nmask] > dp[i][mask] + abs(a[i + 1] - x)) {
          dp[i + 1][nmask] = dp[i][mask] + abs(a[i + 1] - x);
          p[i + 1][nmask] = x;
        }
      }
    }
  }
  int q = 0, mn = inf;
  for (int mask = 0; mask < (1 << 17); ++mask) {
    if (dp[n][mask] < mn) {
      mn = dp[n][mask];
      q = mask;
    }
  }
  vector<int> ans;
  for (int i = n; i >= 1; --i) {
    int number = p[i][q];
    ans.push_back(number);
    q = q ^ premask[number];
  }
  reverse((ans).begin(), (ans).end());
  for (int i = 0; i < (int)ans.size(); ++i) cout << ans[i] << " ";
  return 0;
}