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 <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 150;
const int NP = 17;
int p[NP] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int f[1 << NP], nf[1 << NP], use[N][1 << NP];
int a[N];
int fac[N];
void update(int &a, int b) {
  if (b != -1 && (a == -1 || a > b)) {
    a = b;
  }
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int x = 1; x <= 60; x++) {
    for (int i = 0; i < NP; i++)
      if (x % p[i] == 0) fac[x] |= 1 << i;
  }
  memset(f, -1, sizeof f);
  f[0] = 0;
  for (int i = 0; i < n; i++) {
    memset(nf, -1, sizeof nf);
    for (int mask = 0; mask < (1 << NP); mask++)
      if (f[mask] != -1) {
        for (int x = 1; x <= 60; x++) {
          if ((mask & fac[x]) == 0) {
            int ex = nf[mask | fac[x]];
            update(nf[mask | fac[x]], f[mask] + abs(a[i + 1] - x));
            if (ex != nf[mask | fac[x]]) use[i + 1][mask | fac[x]] = x;
          }
        }
      }
    for (int mask = 0; mask < (1 << NP); mask++) f[mask] = nf[mask];
  }
  int ans = inf, ans_mask = 0;
  for (int mask = 0; mask < (1 << NP); mask++) {
    if (f[mask] != -1 && ans > f[mask]) {
      ans = f[mask];
      ans_mask = mask;
    }
  }
  int mask = ans_mask;
  vector<int> vals;
  for (int i = n; i > 0; i--) {
    vals.push_back(use[i][mask]);
    mask ^= fac[use[i][mask]];
  }
  reverse((vals).begin(), (vals).end());
  for (__typeof((vals).begin()) it = (vals).begin(); it != (vals).end(); it++)
    printf("%d ", *it);
  return 0;
}