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 n, a[105];
int prime[105], tp, ck[105];
int fit[65545][63], tab[105];
int f[105][65545], g[105][65545];
int stk[105], top;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  tp = -1;
  for (int i = 2; i < 59; i++) {
    if (ck[i]) continue;
    prime[++tp] = i;
    for (int j = i; j < 59; j += i) ck[j] = 1;
  }
  for (int i = 1; i <= 58; i++) {
    for (int j = 0; j <= tp; j++)
      if (i % prime[j] == 0) tab[i] |= (1 << j);
  }
  for (int i = 0; i <= 65535; i++)
    for (int j = 1; j <= 58; j++) {
      if (i & tab[j]) continue;
      fit[i][++*fit[i]] = j;
    }
  memset(f, 0x3f, sizeof(f));
  memset(g, -1, sizeof(g));
  f[0][0] = 0;
  g[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 65536; j++)
      if (f[i][j] ^ 0x3f3f3f3f) {
        int upl = a[i + 1] << 1;
        upl -= 2;
        if (upl < 1) upl = 1;
        for (int k = 1; k <= *fit[j]; k++) {
          int go = fit[j][k];
          if (go > upl) break;
          int tmp = f[i][j] + abs(go - a[i + 1]);
          int nxt = j | tab[go];
          if (tmp < f[i + 1][nxt]) {
            f[i + 1][nxt] = tmp;
            g[i + 1][nxt] = go;
          }
        }
      }
  int ans = 0x3f3f3f3f, ans1 = 0, ans2 = 0;
  for (int j = 0; j < 65536; j++)
    if (f[n][j] < ans) {
      ans = f[n][j];
      ans1 = g[n][j];
      ans2 = j;
    }
  for (int i = n - 1; i + 1; i--) {
    stk[++top] = ans1;
    ans2 ^= tab[ans1];
    ans1 = g[i][ans2];
  }
  for (int i = top; i; i--) printf("%d ", stk[i]);
  return 0;
}