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;
vector<int> prime;
int den[61];
const int INF = 1 << 30;
void gen() {
  for (int i = 2; i <= 120; ++i) {
    int ok = 1;
    for (int j = 2; j * j <= i; ++j)
      if (i % j == 0) ok = 0;
    if (ok) prime.push_back(i);
  }
  for (int i = 2; i < 59; ++i) {
    for (int j = 0; prime[j] <= i; ++j)
      if (i % prime[j] == 0) den[i] |= 1 << j;
  }
}
int dp[101][1 << 17];
pair<short, int> par[101][1 << 17];
int n;
int a[102];
void task() {
  ios_base::sync_with_stdio(0);
  fill(par[0], par[0] + 101 * (1 << 17), make_pair(-1, -1));
  fill(dp[0], dp[0] + 101 * (1 << 17), INF);
  gen();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < (1 << 17); ++j)
      if (dp[i][j] != INF) {
        for (int val = 1; val <= 60; ++val) {
          int ok = 1;
          if (den[val] & j) continue;
          int mask = j | den[val];
          if (ok && dp[i][j] + abs(val - a[i]) < dp[i + 1][mask]) {
            dp[i + 1][mask] = dp[i][j] + abs(val - a[i]);
            par[i + 1][mask] = {val, j};
          }
        }
      }
  int mask_ans = 0;
  for (int j = 0; j < (1 << 17); ++j)
    if (dp[n][j] < dp[n][mask_ans]) mask_ans = j;
  (void(1));
  vector<int> ans(n, 0);
  for (int i = n; i > 0; mask_ans = par[i][mask_ans].second, --i) {
    ans[i - 1] = par[i][mask_ans].first;
  }
  for (auto x : ans) cout << x << ' ';
}
int main() {
  task();
  return 0;
}