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 N = 101;
const int INF = 0x3f3f3f3f;
int nxt[N][1 << 11], dp[N][1 << 11], n, ansx[N];
pair<int, int> v[N];
vector<int> primes;
bool isp(int x) {
  if (x == 1) return false;
  for (int j = 2; j * j <= x; j++)
    if (x % j == 0) return false;
  return true;
}
int f(int u, int pr) {
  if (u == n) return 0;
  if (__builtin_popcount(pr) == 10) {
    int rx = 0;
    for (int j = 10; j < primes.size() && u + j - 10 < n; j++)
      rx += abs(v[u + j - 10].first - primes[j]);
    return rx;
  }
  int &ret = dp[u][pr];
  if (ret != -1) return ret;
  ret = INF;
  for (int i = 1; i < N; i++) {
    int ux = 0;
    bool ok = 1;
    for (int j = 0; j < primes.size() && i >= primes[j]; j++)
      if (i % primes[j] == 0) {
        ux |= 1 << j;
        if (j >= 10) {
          ok = false;
          break;
        }
      }
    if (!ok) continue;
    if ((ux & pr) == 0) {
      int fx = f(u + 1, pr | ux) + abs(i - v[u].first);
      if (fx < ret) {
        ret = fx;
        nxt[u][pr] = i;
      }
    }
  }
  return ret;
}
int main(void) {
  ios::sync_with_stdio(false);
  for (int i = 2; primes.size() < 100; i++) {
    if (isp(i)) {
      primes.push_back(i);
    }
  }
  cin >> n;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v, v + n);
  memset(dp, -1, sizeof dp);
  int ans = f(0, 0);
  int x = 0, y = 0, pr = 0, nx = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (__builtin_popcount(pr) == 10) break;
    int u = nxt[i][pr];
    ansx[v[i].second] = u;
    int ux = 0;
    for (int j = 0; j < primes.size() && u >= primes[j]; j++)
      if (u % primes[j] == 0) ux |= 1 << j;
    pr |= ux;
  }
  for (int j = 10; i < n; j++) {
    ansx[v[i].second] = primes[j];
    i++;
  }
  for (int i = 0; i < n; i++) cout << ansx[i] << " ";
  cout << endl;
  return 0;
}