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 comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int Inf = (int)(1e9);
const int S = 1 << 17;
const int N = 100 + 2;
bool isPrime(int x) {
  if (x < 2) return false;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
int son[60], a[N], out[N];
vector<int> prime;
int d[N][S], pre[N][S];
void dfs(int i, int j) {
  if (i == 0)
    return;
  else {
    out[i] = pre[i][j];
    dfs(i - 1, j ^ son[pre[i][j]]);
  }
}
int main() {
  for (int i = 2; i < 60; ++i)
    if (isPrime(i)) prime.push_back(i);
  for (int i = 1; i < 60; ++i)
    for (int j = 0; j < prime.size(); ++j)
      if (i % prime[j] == 0) son[i] |= 1 << j;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  memset(pre, -1, sizeof pre);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j < S; ++j) d[i][j] = Inf;
  d[0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < S; ++j)
      if (d[i][j] != Inf) {
        for (int k = 1; k < 60; ++k)
          if ((son[k] & j) == 0) {
            if (d[i + 1][son[k] | j] >= d[i][j] + abs(a[i] - k)) {
              d[i + 1][son[k] | j] = d[i][j] + abs(a[i] - k);
              pre[i + 1][son[k] | j] = k;
            }
          }
      }
  int ansv = Inf, ansj;
  for (int j = 0; j < S; ++j)
    if (d[n][j] <= ansv) {
      ansv = d[n][j];
      ansj = j;
    }
  dfs(n, ansj);
  for (int i = 1; i <= n; ++i) {
    if (i > 1) putchar(' ');
    printf("%d", out[i]);
  }
  puts("");
  return 0;
}