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 primes[17] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                        29, 31, 37, 41, 43, 47, 53, 59};
int N, A[110], dp[110][1 << 17], s[60];
const int Field = 0x1FFFF;
int main() {
  scanf("%d", &N);
  int i;
  for (i = 0; i <= N - 1; i++) scanf("%d", &A[i]);
  for (i = 1; i <= 59; i++) s[i] = 0;
  for (i = 0; i <= 16; i++)
    for (int j = primes[i]; j < 60; j += primes[i]) s[j] |= 1 << i;
  int j, k;
  for (i = 0; i <= N; i++)
    for (j = 0; j <= Field; j++) dp[i][j] = 0x23333333;
  dp[0][0] = 0;
  for (i = 0; i <= N - 1; i++)
    for (k = 1; k <= 59; k++)
      for (int f = j = (Field ^ s[k]);; j = (j - 1) & f) {
        dp[i + 1][j ^ s[k]] =
            min(dp[i + 1][j ^ s[k]], dp[i][j] + abs(A[i] - k));
        if (j == 0) break;
      }
  vector<int> RET;
  RET.clear();
  int ans = 0x23333333;
  int lv, u = 0;
  for (i = 0; i <= Field; i++)
    if (ans > dp[N][i]) {
      ans = dp[N][i];
      u = i;
    }
  for (lv = N - 1; lv >= 0; lv--)
    for (k = 1; k <= 59; k++)
      if (((u & s[k]) == s[k]) &&
          (dp[lv][u ^ s[k]] + abs(k - A[lv]) == dp[lv + 1][u])) {
        RET.push_back(k);
        u ^= s[k];
        break;
      }
  for (i = 1; i <= N; i++) printf("%d%s", RET[N - i], (i == N) ? "\n" : " ");
}