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;
bool check(long long s) {
  for (long long i = 2, _b = sqrt(s); i <= _b; i++)
    if (s % i == 0) return false;
  return true;
}
vector<long long> snt, ans;
int bd[66], dp[102][1 << 17], gt[102][1 << 17], res = 1e9, n, a[103], now;
pair<long long, long long> lu;
void Solve() {
  cin >> n;
  for (long long i = 1, _b = n; i <= _b; i++) cin >> a[i];
  for (long long i = 2, _b = 60; i <= _b; i++)
    if (check(i)) snt.push_back(i);
  for (long long i = 2, _b = 60; i <= _b; i++) {
    long long b = 0;
    for (long long j = 0, _b = snt.size(); j < _b; j++) {
      if (i % snt[j] == 0) b |= (1 << j);
    }
    bd[i] = b;
  }
  for (long long i = 0, _b = n; i <= _b; i++)
    for (long long j = 0, _b = 1 << 17; j <= _b; j++) dp[i][j] = 1e9;
  dp[0][0] = 0;
  for (long long i = 1, _b = n; i <= _b; i++) {
    for (long long id = 1, _b = 59; id <= _b; id++) {
      long long x = (~bd[id]) & ((1 << 17) - 1);
      long long s = x;
      while (1) {
        if (dp[i][s | bd[id]] > dp[i - 1][s] + abs(a[i] - id)) {
          dp[i][s | bd[id]] = dp[i - 1][s] + abs(a[i] - id);
          gt[i][s | bd[id]] = id;
        }
        if (s == 0) break;
        s = (s - 1) & x;
      }
    }
  }
  for (long long i = 0, _b = 1 << 17; i < _b; i++)
    if (res > dp[n][i]) {
      res = dp[n][i];
      lu = {n, i};
    }
  for (long long i = 1, _b = n; i <= _b; i++) {
    long long tmp = gt[lu.first][lu.second];
    ans.push_back(tmp);
    lu.second -= bd[tmp];
    lu.first--;
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << " ";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}