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 MaxN = 110;
const int inf = 1e9;
inline int myabs(int x) { return x < 0 ? -x : x; }
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
bool np[65];
vector<int> P;
void eratosten(void) {
  for (int x = 2; x <= 60; ++x)
    if (!np[x]) {
      P.push_back(x);
      for (int y = 2; x * y <= 60; ++y) np[x * y] = true;
    }
}
int dp[MaxN][(1 << 17) + 10];
int N, a[MaxN], idx[MaxN];
bool ok[MaxN][MaxN];
vector<int> cand[(1 << 17) + 10], nmask[(1 << 17) + 10];
vector<int> ans;
bool cmpf(int i, int j) { return a[i] < a[j]; }
int f(int i, int mask) {
  if (i == N) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  if (i < N - 18) return dp[i][mask] = f(i + 1, mask) + myabs(a[i] - 1);
  int ret = inf;
  for (int j = 0; j < cand[mask].size(); ++j) {
    int x = cand[mask][j];
    ret = min(ret, f(i + 1, nmask[mask][j]) + myabs(a[i] - x));
  }
  return dp[i][mask] = ret;
}
void rec(int i, int mask) {
  if (i == N) return;
  int ret = f(i, mask);
  if (i < N - 17) {
    ans.push_back(1);
    rec(i + 1, mask);
    return;
  }
  for (int j = 0; j < cand[mask].size(); ++j) {
    int x = cand[mask][j];
    if (ret == f(i + 1, nmask[mask][j]) + myabs(a[i] - x)) {
      ans.push_back(x);
      rec(i + 1, nmask[mask][j]);
      return;
    }
  }
}
void init(void) {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < N; ++i) idx[i] = i;
  sort(idx, idx + N, cmpf);
  sort(a, a + N);
  for (int x = 1; x <= 60; ++x)
    for (int i = 0; i < P.size(); ++i)
      if (gcd(x, P[i]) == 1) ok[x][P[i]] = true;
  for (int mask = 0; mask < (1 << (int)P.size()); ++mask)
    for (int x = 1; x <= 60; ++x) {
      bool flag = false;
      int nm = mask;
      for (int j = 0; j < P.size(); ++j)
        if (!ok[x][P[j]] && (mask & (1 << j)) != 0) {
          flag = true;
          break;
        }
      if (!flag) {
        cand[mask].push_back(x);
        for (int j = 0; j < P.size(); ++j)
          if (!ok[x][P[j]]) nm |= 1 << j;
        nmask[mask].push_back(nm);
      }
    }
}
int res[MaxN];
int main(void) {
  eratosten();
  init();
  rec(0, 0);
  for (int i = 0; i < ans.size(); ++i) res[idx[i]] = ans[i];
  for (int i = 0; i < N; ++i) printf("%d ", res[i]);
  printf("\n");
  return 0;
}