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 pri[105], num[105], zy[105];
int G[65540][60], sz[65540];
int dp[105][65540], jl[105][65540], fr[105][65540];
bool vis[105] = {0};
void getprime() {
  int i, j, cou = 0;
  for (i = 2; i <= 60; i++)
    if (!vis[i]) {
      num[i] = cou;
      pri[++cou] = i;
      for (j = i * i; j <= 60; j += i) vis[j] = 1;
    }
}
void init() {
  int i, j;
  zy[1] = 0;
  for (i = 2; i <= 58; i++)
    for (j = 2; j <= 58; j++)
      if (!vis[j] && i % j == 0) zy[i] |= (1 << num[j]);
  for (i = 0; i < (1 << 16); i++) {
    sz[i] = 1;
    G[i][1] = 1;
    for (j = 2; j <= 58; j++)
      if (!(i & zy[j])) {
        G[i][++sz[i]] = j;
      }
  }
}
int a[105], b[105];
void inline update(int i, int j, int c, int fj, int k) {
  if (dp[i][j] == -1 || dp[i][j] > c) {
    dp[i][j] = c;
    fr[i][j] = fj;
    jl[i][j] = k;
  }
}
int main() {
  getprime();
  init();
  int n, i, j, k, c, minw = 100000000, minj;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[0][0] = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < (1 << 16); j++)
      if (dp[i][j] != -1) {
        for (k = 1; k <= sz[j]; k++) {
          c = G[j][k];
          update(i + 1, j | zy[c], abs(a[i + 1] - c) + dp[i][j], j, c);
        }
      }
  }
  for (j = 0; j < (1 << 16); j++)
    if (dp[n][j] != -1)
      if (dp[n][j] < minw) minw = dp[n][j], minj = j;
  j = minj;
  for (i = n; i; i--) {
    b[i] = jl[i][j];
    j = fr[i][j];
  }
  for (i = 1; i <= n; i++) printf("%d ", b[i]);
  return 0;
}