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;
void read_file(bool outToFile = true) {}
int n;
const int nMax = 100;
int A[nMax];
const int pMax = 58 + 1;
const int pszMax = 16;
bitset<pMax> isPrime;
int prime[pszMax];
int indexOf[pMax];
int divv[pMax];
void sieve() {
  isPrime.set();
  isPrime[0] = isPrime[1] = 0;
  int prime_idx = 0;
  for (int i = 2; i < pMax; i++) {
    if (!isPrime[i]) continue;
    prime[prime_idx] = i;
    indexOf[i] = prime_idx;
    prime_idx++;
    divv[i] = i;
    for (int j = i * i; j < pMax; j += i) isPrime[j] = 0, divv[j] = i;
  }
  assert(prime_idx == 16);
}
const int AiMax = 30 + 1;
int memo[nMax][(1 << pszMax)];
int memov[pMax][(1 << pszMax)];
vector<pair<int, int> > V[(1 << pszMax)];
int valid(int x, int mask) {
  int &nmask = memov[x][mask];
  if (nmask != -1) return nmask;
  nmask = mask;
  while (x != 1) {
    int pf = divv[x];
    if (mask & (1 << indexOf[pf])) {
      return nmask = -2;
    }
    x /= pf;
    nmask = nmask | (1 << indexOf[pf]);
  }
  return nmask;
}
void prepro() {
  for (int mask = 0; mask < (1 << pszMax); mask++) {
    for (int k = 1; k < pMax; k++) {
      int nmask = valid(k, mask);
      if (nmask != -2) V[mask].push_back(make_pair(nmask, k));
    }
  }
}
int rec(int i = 0, int mask = 0) {
  if (i == n) return 0;
  int &ret = memo[i][mask];
  if (ret != -1) return ret;
  ret = (1000000000);
  int tmp = max(1, 2 * A[i] - 2);
  int sz = V[mask].size();
  for (int j = 0; j < sz; j++) {
    int k = V[mask][j].second;
    int nmask = V[mask][j].first;
    if (k > tmp) break;
    ret = min(ret, rec(i + 1, nmask) + abs(A[i] - k));
  }
  return ret;
}
void trace(int i = 0, int mask = 0) {
  if (i == n) return;
  int ret = rec(i, mask);
  int tmp = max(1, 2 * A[i] - 2);
  int sz = V[mask].size();
  for (int j = 0; j < sz; j++) {
    int k = V[mask][j].second;
    int nmask = V[mask][j].first;
    if (k > tmp) break;
    int nw = rec(i + 1, nmask) + abs(A[i] - k);
    if (nw != ret) continue;
    printf("%d%c", k, " \n"[i == n - 1]);
    trace(i + 1, nmask);
    return;
  }
  assert(0);
}
int main() {
  read_file();
  sieve();
  memset(memov, -1, sizeof memov);
  prepro();
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    memset(memo, -1, sizeof memo);
    trace();
  }
}