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 dp[101][101][256];
int p1[110], p2[110];
int cnt1, cnt2, n, m;
int bao[110];
int isp(int n) {
  for (int i = 2; i < n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int sta[110], top;
struct node {
  int val, id;
} a[110];
int cmp(node a, node b) { return a.val < b.val; }
int pre[110][110][256];
void upd(int &nn, int &m, int k, int kk) {
  if (nn < 0 || nn > k) nn = k, m = kk;
}
int an[110];
void out(int i, int j, int k) {
  if (i == 0) return;
  int ii, jj, kk;
  int t = pre[i][j][k];
  ii = t / 30000, t %= 30000;
  jj = t / 256, t %= 256;
  kk = t;
  if (jj == j - 1)
    an[a[i].id] = p2[jj];
  else {
    k -= kk;
    int m = 2100000, ind;
    for (j = 0; j < top; j++)
      if (bao[sta[j]] == k) {
        if (m > abs(a[i].val - sta[j]))
          m = min(m, abs(a[i].val - sta[j])), ind = sta[j];
      }
    an[a[i].id] = ind;
  }
  out(ii, jj, kk);
}
void init() {
  int i, j, k;
  cnt1 = cnt2 = 0;
  for (i = 2;; i++)
    if (isp(i)) {
      if (i <= 19)
        p1[cnt1++] = i;
      else
        p2[cnt2++] = i;
      if (cnt2 == 100) break;
    }
  for (i = 1; i <= 50; i++) {
    for (j = 0; j < cnt1; j++)
      if (i % p1[j] == 0) bao[i] |= 1 << j;
    if (i <= 19 || (!isp(i) && i != 46)) sta[top++] = i;
  }
  sta[top++] = 1;
}
int DP() {
  int i, j, k;
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < 256; k++)
        if (dp[i][j][k] >= 0) {
          upd(dp[i + 1][j + 1][k], pre[i + 1][j + 1][k],
              dp[i][j][k] + abs(p2[j] - a[i + 1].val), i * 30000 + j * 256 + k);
          for (int t = 0; t < top; t++)
            if (!(k & bao[sta[t]]))
              upd(dp[i + 1][j][k | bao[sta[t]]], pre[i + 1][j][k | bao[sta[t]]],
                  dp[i][j][k] + abs(sta[t] - a[i + 1].val),
                  i * 30000 + j * 256 + k);
        }
  int ans = -1;
  for (i = 0; i <= n; i++)
    for (j = 0; j < 256; j++)
      if (dp[n][i][j] >= 0) {
        if (ans < 0 || ans > dp[n][i][j]) ans = dp[n][i][j];
      }
  return ans;
}
void gao(int ans) {
  int i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j < 256; j++)
      if (dp[n][i][j] == ans) {
        out(n, i, j);
        break;
      }
    if (j < 256) break;
  }
  for (i = 1; i <= n; i++) printf("%d ", an[i]);
  puts("");
}
int main() {
  int i, j, k;
  init();
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i].val), a[i].id = i;
    sort(a + 1, a + 1 + n, cmp);
    int ret = DP();
    gao(ret);
  }
}