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;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
bool vis[60];
vector<int> p;
int fac[60];
int n;
int a[105];
void sieve() {
  vis[0] = vis[1] = 1;
  for (int i = 2; i < 60; i++) {
    if (vis[i]) continue;
    p.push_back(i);
    for (int j = 2 * i; j < 60; j += i) vis[j] = 1;
  }
}
int pos[105][1 << (18)];
int dp[105][1 << (18)];
int solve(int id, int s) {
  if (id == n) return 0;
  if (dp[id][s] != -1) return dp[id][s];
  int re = abs(a[id] - 1) + solve(id + 1, s);
  pos[id][s] = 1;
  for (int i = 2; i < 60; i++) {
    if ((fac[i] & s) == fac[i]) {
      int y = abs(a[id] - i) + solve(id + 1, s ^ fac[i]);
      if (re > y) {
        re = y;
        pos[id][s] = i;
      }
    }
  }
  return dp[id][s] = re;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sieve();
  for (int i = 2; i < 60; i++) {
    for (int j = 0; j < p.size(); j++) {
      if (i % p[j] == 0) {
        fac[i] |= (1 << j);
      }
    }
  }
  memset(dp, -1, sizeof dp);
  int fullmask = (1 << 17) - 1;
  solve(0, fullmask);
  int s = fullmask;
  for (int i = 0; i < n; i++) {
    int y = pos[i][s];
    cout << y << " ";
    s ^= fac[y];
  }
}