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 inf = 1073741823;
const int maxint = 0x7fffffff;
const long long INF = 1152921504606846976ll;
const long double eps = 1E-9;
const long double pi = acos(-1);
template <class T>
inline T _sqr(T a) {
  return (a * a);
}
template <class T>
inline T _abs(T a) {
  return (a >= 0 ? a : -a);
}
template <class T>
inline T _lbt(T a) {
  return (a & (a ^ (a - 1)));
}
template <class T>
inline T _max(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
inline T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
inline T _smax(T a, T b, T c) {
  return _max(_max(a, b), c);
}
template <class T>
inline T _smin(T a, T b, T c) {
  return _min(_min(a, b), c);
}
template <class T>
inline T _sqrt(T a) {
  T b, c;
  for (b = sqrt(a), c = b - 2; c <= b + 2; c++)
    if (_sqr(c) <= a) b = c;
  return b;
}
template <class T>
inline T _pow(T a, T b, T c) {
  T d = 1;
  for (a %= c; b; b >>= 1, a = a * a % c)
    if (b & 1) d = d * a % c;
  return d;
}
int n, m, k, t, x, y, p, T;
int f[111][(1 << 12)][10], choice[111][(1 << 12)][10], a[111], b[111];
int zz[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int prime[] = {31, 37, 41, 43, 47, 53, 59};
int state[111], tt[111];
void Solution_Production() {
  scanf("%d", &n);
  for (int i = 1; i <= 60; i++) {
    for (int j = 0; j < 10; j++)
      if (i % zz[j] == 0) state[i] |= 1 << j;
  }
  for (int i = 1; i <= 60; i++) tt[i] = false;
  for (int i = 0; i < 7; i++) tt[prime[i]] = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 10); j++)
      for (int k = 0; k < 8; k++) f[i][j][k] = inf;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 10); j++)
      for (int k = 0; k < 8; k++) {
        if (k && f[i - 1][j][k - 1] + abs(prime[k - 1] - a[i]) < f[i][j][k]) {
          f[i][j][k] = f[i - 1][j][k - 1] + abs(prime[k - 1] - a[i]);
          choice[i][j][k] = prime[k - 1];
        }
        for (int o = 1; o <= 60; o++)
          if (!tt[o] && ((j & state[o]) == state[o])) {
            if (f[i - 1][j ^ state[o]][k] + abs(a[i] - o) < f[i][j][k]) {
              choice[i][j][k] = o;
              f[i][j][k] = f[i - 1][j ^ state[o]][k] + abs(a[i] - o);
            }
          }
      }
  int mx, my, ans = inf;
  for (int mask = 0; mask < (1 << 10); mask++)
    for (int j = 0; j < 8; j++)
      if (f[n][mask][j] < ans) {
        ans = f[n][mask][j];
        mx = mask;
        my = j;
      }
  for (int i = n; i >= 1; i--) {
    b[i] = choice[i][mx][my];
    if (tt[b[i]]) {
      my--;
    } else {
      mx ^= state[b[i]];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", b[i]);
}
int main() {
  Solution_Production();
  return 0;
}