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 long double eps = 1e-9;
const long double pi = acos(-1.0);
const long long inf = 1e+9;
#pragma comment(linker, "/STACK:36777216")
template <typename T>
istream &operator>>(istream &, vector<T> &);
template <typename T>
ostream &operator<<(ostream &, const vector<T> &);
int get(int v, const vector<int> &pr) {
  int mask = 0;
  while (v > 1) {
    for (int i = 0; i < 17; i++) {
      if (v % pr[i] == 0) {
        while (v % pr[i] == 0) v /= pr[i];
        mask |= (1 << i);
      }
    }
  }
  return mask;
}
int main() {
  clock_t _clock = clock();
  vector<int> pr(1005, 1);
  pr[0] = pr[1] = false;
  for (int i = 2; i * i <= 1000; i++) {
    if (pr[i]) {
      for (int j = i * i; j <= 1000; j += i) {
        pr[j] = 0;
      }
    }
  }
  vector<int> prime;
  for (int i = 2; i <= 1000; i++) {
    if (pr[i]) prime.push_back(i);
  }
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> masks(60);
  for (int i = 1; i < 60; i++) {
    masks[i] = get(i, prime);
  }
  vector<vector<int> > dp(n + 1, vector<int>(1 << 17, inf));
  vector<vector<int> > par(n + 1, vector<int>(1 << 17, -1));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int mask = 0; mask < (1 << 17); mask++) {
      for (int v = 1; v < 60; v++) {
        if ((mask & masks[v]) == 0) {
          if (dp[i][mask | masks[v]] > dp[i - 1][mask] + abs(v - a[i - 1])) {
            dp[i][mask | masks[v]] = dp[i - 1][mask] + abs(v - a[i - 1]);
            par[i][mask | masks[v]] = v;
          }
        }
      }
    }
  }
  int minMask = min_element(dp[n].begin(), dp[n].end()) - dp[n].begin();
  int j = n;
  vector<int> ans;
  while (par[j][minMask] != -1) {
    ans.push_back(par[j][minMask]);
    minMask ^= masks[par[j][minMask]];
    j--;
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) is >> v[i];
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) os << v[i] << " ";
  return os;
}