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 cnt = 0;
int c[123], a[123];
int dp[101][(1 << 16) + 5];
int pre[101][(1 << 16) + 5][2];
int b[123] = {0};
int p[123];
void prime() {
  for (int i = 2; i < 60; i++)
    if (!b[i]) {
      p[++cnt] = i;
      for (int j = i + i; j < 60; j += i) b[j] = 1;
    }
}
int cal(int x) {
  int ans = 0;
  for (int i = 1; i <= cnt; i++) {
    if (x % p[i] == 0) ans |= (1 << (i - 1));
    while (x % p[i] == 0) x /= p[i];
  }
  return ans;
}
void print(int x, int pos) {
  if (x == 0) return;
  print(x - 1, pre[x][pos][0]);
  cout << pre[x][pos][1] << " ";
}
int main() {
  int n;
  prime();
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < 60; i++) c[i] = cal(i);
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  memset(dp[0], 0, sizeof(dp[0]));
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 16); j++)
      for (int k = 1; k < 60; k++)
        if ((j & c[k]) == c[k]) {
          int tmp = dp[i - 1][j ^ c[k]] + abs(k - a[i]);
          if (dp[i][j] > tmp) {
            dp[i][j] = tmp;
            pre[i][j][0] = (j ^ c[k]);
            pre[i][j][1] = k;
          }
        }
  int min = 0x3f3f3f3f, pos;
  for (int i = 0; i < (1 << 16); i++)
    if (dp[n][i] < min) {
      min = dp[n][i];
      pos = i;
    }
  print(n, pos);
  return 0;
}