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 double EPS = 1e-7;
const double PI = acos(-1.0);
const double ZERO = 0;
const double DOUBLE_MAX = 1 / ZERO;
vector<vector<int> > fact(62);
int n;
vector<int> a(101);
vector<int> prim;
int dp[101][1 << 19];
int pr[65] = {0};
vector<int> sol(101);
int solve(int id, int mask) {
  if (id == n) {
    return 0;
  }
  if (dp[id][mask] != -1) return dp[id][mask];
  int res = a[id] - 1 + solve(id + 1, mask);
  sol[id] = 1;
  for (int i = 2; i < 58; i++) {
    int msk = mask;
    bool ok = 1;
    for (int j = 0; j < fact[i].size(); j++) {
      if (1 << pr[fact[i][j]] & mask) {
        ok = 0;
        break;
      }
      msk |= (1 << pr[fact[i][j]]);
    }
    if (!ok) continue;
    if (res > abs(a[id] - i) + solve(id + 1, msk)) {
      res = abs(a[id] - i) + solve(id + 1, msk);
    }
  }
  return dp[id][mask] = res;
}
void print(int id, int mask) {
  if (id == n) return;
  int res = (0x7fffffff), x, ms;
  for (int i = 1; i < 58; i++) {
    int msk = mask;
    bool ok = 1;
    for (int j = 0; j < fact[i].size(); j++) {
      if (1 << pr[fact[i][j]] & mask) {
        ok = 0;
        break;
      }
      msk |= (1 << pr[fact[i][j]]);
    }
    if (!ok) continue;
    if (id == n - 1) {
      if (abs(a[id] - i) < res) {
        res = abs(a[id] - i);
        x = i;
        ms = msk;
      }
    } else if (dp[id + 1][msk] != -1 &&
               dp[id + 1][msk] + abs(a[id] - i) < res) {
      res = abs(a[id] - i) + dp[id + 1][msk];
      x = i;
      ms = msk;
    }
  }
  cout << x << " ";
  print(id + 1, ms);
}
int main() {
  memset(dp, -1, sizeof dp);
  for (int i = 1; i < 62; i++) {
    int k = i, p = 2;
    while (k != 1) {
      while (k % p) p++;
      fact[i].push_back(p);
      while (k % p == 0) k /= p;
    }
  }
  int p[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31,
             37, 39, 41, 43, 47, 51, 53, 57, 59, 61};
  prim = vector<int>(p, p + 21);
  for (int i = 0; i < prim.size(); i++) pr[prim[i]] = i;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(0, 0);
  print(0, 0);
  return 0;
}