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<long long int> p[300005], g(120005), b(405, 0), a(405, 0);
long long int f[120005];
vector<long long int> v = {2,  3,  5,  7,  11, 13, 17, 19,
                           23, 29, 31, 37, 41, 43, 47, 53};
vector<vector<long long int>> dp(105, vector<long long int>((1 << 16), 0));
vector<vector<long long int>> ans(105, vector<long long int>((1 << 16), 0));
map<pair<long long int, long long int>, long long int> mp;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int bpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000009;
    a = (a * a) % 1000000009;
    b >>= 1;
  }
  return res % 1000000009;
}
void fact(long long int i) {
  f[0] = 1;
  for (long long int k = 1; k <= i; k++) {
    (f[k] = f[k - 1] * k) %= 1000000009;
  }
}
long long int isprime(long long int n) {
  if (n == 1) return 0;
  for (long long int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
long long int find(long long int x) {
  if (f[x] == x)
    return x;
  else
    return f[x] = find(f[x]);
}
bool cmp(long long int x, long long int y) { return x < y; }
long long int comb(long long int i, long long int j) {
  if (j > i) return 0;
  long long int k = f[i];
  long long int g = (f[j] * (f[i - j])) % 1000000009;
  long long int h = bpow(g, 1000000009 - 2);
  return (k * h) % 1000000009;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (long long int i = 1; i <= 60; i++) {
    for (long long int j = 0; j < v.size(); j++) {
      if (i % v[j] == 0) b[i] |= (1 << j);
    }
  }
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long int i = n; i >= 1; i--) {
    for (long long int mask = 0; mask < (1 << 16); mask++) {
      dp[i][mask] = 1e18;
      for (long long int k = 1; k < 60; k++) {
        if (!(b[k] & mask)) {
          long long int u = dp[i + 1][b[k] | mask] + abs(a[i] - k);
          if (dp[i][mask] > u) {
            dp[i][mask] = u;
            ans[i][mask] = k;
          }
        }
      }
    }
  }
  long long int mask = 0;
  for (long long int i = 1; i <= n; i++) {
    cout << ans[i][mask] << " ";
    mask |= b[ans[i][mask]];
  }
  cout << "\n";
}