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 N = 1e2 + 6;
const int Log2 = 19;
const int inf = 1e9 + 7;
vector<int> ans;
int prime[10] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int outer[7] = {31, 37, 41, 43, 47, 53, 59};
bool dd[N];
int n, a[N], dp[103][1048][9];
bool chk(int n, int state) {
  for (int i = 0; i < 10; i++) {
    if (n % prime[i] == 0) {
      if ((state & (1 << i))) return 0;
    }
  }
  return 1;
}
int oper(int n, int state) {
  int res = state;
  for (int i = 0; i < 10; i++) {
    if (n % prime[i] == 0) res |= (1 << i);
  }
  return res;
}
int f(int pos, int state, int out) {
  if (pos > n) return 0;
  if (dp[pos][state][out] != -1) return dp[pos][state][out];
  int ans = inf;
  for (int i = 1; i <= 60; i++) {
    if (chk(i, state) && !dd[i]) {
      int res = oper(i, state);
      ans = min(ans, abs(a[pos] - i) + f(pos + 1, res, out));
    }
  }
  if (out < 7)
    ans = min(ans, abs(a[pos] - outer[out]) + f(pos + 1, state, out + 1));
  return dp[pos][state][out] = ans;
}
void Trace(int pos, int state, int out) {
  if (pos > n) return;
  for (int i = 1; i <= 60; i++) {
    if (chk(i, state) && !dd[i]) {
      int res = oper(i, state);
      if (f(pos, state, out) == abs(a[pos] - i) + f(pos + 1, res, out)) {
        ans.push_back(i);
        Trace(pos + 1, res, out);
        return;
      }
    }
  }
  if (out < 7 && f(pos, state, out) ==
                     abs(a[pos] - outer[out]) + f(pos + 1, state, out + 1))
    ans.push_back(outer[out]), Trace(pos + 1, state, out + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("tst"
            ".inp",
            "r")) {
    freopen(
        "tst"
        ".inp",
        "r", stdin);
  }
  for (int i = 0; i < 7; i++) dd[outer[i]] = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  Trace(1, 0, 0);
  for (auto i : ans) cout << i << " ";
}