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 inf = 0x3f3f3f3f;
bool is_prime[61];
vector<int> prime;
int n, up, a[105], v[61], dp[105][1 << 17];
int pre[100][1 << 17];
void get_prime() {
  memset(is_prime, true, sizeof(is_prime));
  is_prime[1] = false;
  for (int i = 2; i <= 60; i++) {
    if (!is_prime[i]) continue;
    prime.push_back(i);
    for (int j = i * 2; j <= 60; j += i) is_prime[j] = false;
  }
}
int main() {
  get_prime();
  up = 1 << (prime.size());
  memset(dp, inf, sizeof(dp));
  memset(pre, -1, sizeof(pre));
  for (int i = 1; i <= 60; i++) {
    int x = 0;
    for (int j = 0; j < prime.size(); j++) {
      if (i % prime[j] == 0) x |= 1 << j;
    }
    v[i] = x;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < up; j++) {
      for (int k = 1; k <= 60; k++) {
        if ((j & v[k]) == 0) {
          if (dp[i][j] + abs(k - a[i + 1]) < dp[i + 1][j | v[k]]) {
            pre[i + 1][j | v[k]] = j;
            dp[i + 1][j | v[k]] = dp[i][j] + abs(k - a[i + 1]);
          }
        }
      }
    }
  }
  int item = 0;
  for (int i = 0; i < up; i++)
    if (dp[n][i] < dp[n][item]) item = i;
  int cur = item, p = item, op = n;
  vector<int> ans;
  while (pre[op][cur] != -1) {
    cur = pre[op][cur];
    int xr = cur ^ p, g = -1;
    for (int i = 1; i <= 60; i++) {
      if (v[i] == xr) {
        if (g == -1 || abs(a[op] - g) > abs(a[op] - i)) g = i;
      }
    }
    ans.push_back(g);
    p = cur;
    op--;
  }
  for (int i = ans.size() - 1; i >= 0; i--) printf("%d ", ans[i]);
  puts("");
  return 0;
}