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;
const int N = 103;
const int MAXA = 30;
const int MAXB = 59;
const int MAXP = 16;
const int MAXM = 1 << 16;
pair<int, int> A[N];
int n, B[N], pMask[MAXB];
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int dp[N][MAXM], path[N][MAXM];
void work() {
  int i, j, m;
  for (i = 2; i < MAXB; i++) {
    pMask[i] = 0;
    for (j = 0; j < MAXP; j++)
      if (i % primes[j] == 0) pMask[i] |= (1 << j);
  }
  for (i = max(0, n - MAXP); i <= n; i++) {
    for (j = 0; j < MAXM; j++) dp[i][j] = 2000000000;
  }
  for (i = 0; i < n - MAXP; i++)
    dp[i + 1][0] = dp[i][0] + A[i].first - 1, path[i + 1][0] = 1;
  dp[0][0] = 0;
}
void _dp() {
  int i, j, b;
  for (i = max(0, n - MAXP); i < n; i++) {
    for (j = 0; j < MAXM; j++) {
      if (dp[i][j] == 2000000000) continue;
      for (b = 1; b < MAXB; b++) {
        if (!(j & pMask[b])) {
          int t = dp[i][j] + abs(A[i].first - b);
          if (t < dp[i + 1][j | pMask[b]])
            dp[i + 1][j | pMask[b]] = t, path[i + 1][j | pMask[b]] = b;
        }
      }
    }
  }
}
void _path() {
  int idx, j, m = 0, ans = dp[n][0];
  for (j = 0; j < MAXM; j++)
    if (dp[n][j] < ans) ans = dp[n][j], m = j;
  idx = n;
  while (idx) {
    int p = path[idx][m];
    B[A[idx - 1].second] = p;
    m -= pMask[p];
    idx--;
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i].first, A[i].second = i;
  sort(A, A + n);
  work();
  _dp();
  _path();
  for (int i = 0; i < n; i++) cout << B[i] << " ";
  return 0;
}