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>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = acos(-1);
const int N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 2e18;
long long xyp(long long x, long long y) {
  if (y == 0) return 1LL;
  if (y == 1) return x;
  if (y % 2) {
    long long p = xyp(x, y - 1);
    return (x * p) % mod;
  }
  long long p = xyp(x, y / 2);
  return (p * p) % mod;
}
long long add(long long a, long long b) {
  return (a % mod + b % mod + mod) % mod;
}
long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod) + mod) % mod;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> second) {
  os << "{ ";
  for (auto s : second) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream& operator<<(ostream& os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ")";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int factormask[59], a[105], n;
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
void pre() {
  for (int i = 1; i < 59; i++) {
    factormask[i] = 0;
    for (int j = 0; j < 16; j++) {
      if (i % p[j] == 0) {
        factormask[i] |= (1 << j);
      }
    }
  }
}
int DP[101][1 << 16], b[101][1 << 16];
int calc(int i, int mask) {
  if (i == 0) return 0;
  if (DP[i][mask] != -1) return DP[i][mask];
  DP[i][mask] = calc(i - 1, mask) + abs(a[i] - 1);
  b[i][mask] = 1;
  for (int j = 2; j < 59; j++) {
    if ((mask & factormask[j]) != factormask[j]) continue;
    int cur = calc(i - 1, mask ^ factormask[j]) + abs(a[i] - j);
    if (cur < DP[i][mask]) {
      DP[i][mask] = cur;
      b[i][mask] = j;
    }
  }
  return DP[i][mask];
}
int main() {
  pre();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(25);
  {
    memset(DP, -1, sizeof(DP));
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int fullmask = (1 << 16) - 1;
    calc(n, fullmask);
    vector<int> b_out(n + 1);
    for (int i = n, mask = fullmask; i > 0; i--) {
      int cur = b[i][mask];
      b_out[i] = cur;
      mask ^= factormask[cur];
    }
    for (int i = 1; i <= n; i++) cout << b_out[i] << " ";
    cout << endl;
  }
  return 0;
}