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;
int a[109];
bool flag[100];
int prime[100], r[100];
int x[20], tol, res;
const int maxn = (1 << 17) + 100;
int dp[109][maxn];
int pre[109][maxn];
int b[100];
void init() {
  int i, j;
  for (i = 1; i <= 60; i++) {
    int u = 0;
    if (prime[i] == 1)
      r[i] = 0;
    else {
      for (j = 1; j <= res; j++) {
        if (prime[i] % x[j] == 0) u += (1 << (j - 1));
      }
    }
    r[i] = u;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int i, j, k;
  for (i = 1; i <= 60; i++) flag[i] = true;
  tol = 0;
  memset(dp, -1, sizeof(dp));
  res = 0;
  for (i = 2; i <= 59; i++) {
    if (flag[i]) {
      x[++res] = i;
      for (j = i + i; j <= 60; j += i) flag[j] = false;
    }
  }
  for (i = 1; i <= 30; i++) {
    prime[++tol] = i;
  }
  for (i = 31; i <= 59; i++) prime[++tol] = i;
  init();
  dp[0][0] = 0;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    for (j = 0; j < maxn; j++)
      if (dp[i - 1][j] != -1) {
        for (k = 60; k >= 1; k--) {
          if ((r[k] & j) == 0) {
            if (dp[i][r[k] ^ j] == -1 ||
                dp[i][r[k] ^ j] > dp[i - 1][j] + abs(a[i] - prime[k])) {
              dp[i][r[k] ^ j] = dp[i - 1][j] + abs(a[i] - prime[k]);
              pre[i][r[k] ^ j] = k;
            }
          }
        }
      }
  }
  int ans = 29000000, which = -1;
  for (i = 0; i < maxn; i++)
    if (dp[n][i] != -1) {
      if (ans > dp[n][i]) ans = dp[n][i], which = i;
    }
  int y = 0;
  i = n;
  j = which;
  while (i) {
    b[++y] = pre[i][j];
    j = (j ^ r[pre[i][j]]);
    i--;
  }
  for (i = y; i >= 1; i--) {
    if (i == y)
      printf("%d", b[i]);
    else
      printf(" %d", b[i]);
  }
  puts("");
  return 0;
}