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 MAXINT = 0x70707070;
const long long MAXLONG = (long long)1 << 60;
const int MAXN = 101;
const int MAXV = 61;
int dp[MAXN][1 << 17], pre[MAXN][1 << 17], corr[MAXN][1 << 17];
int bm[MAXV];
int arr[MAXN];
vector<int> primes;
int n;
void find_prime() {
  for (long long i = (2); i < (MAXV); i += 1) {
    bool ok = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      primes.push_back(i);
    }
  }
}
void find_factor() {
  for (long long i = (1); i < (MAXV); i += 1) {
    int bit = 0;
    for (long long j = (0); j < (primes.size()); j += 1) {
      int p = primes[j];
      if (i % p == 0) {
        bit |= 1 << j;
      }
    }
    bm[i] = bit;
  }
}
int main() {
  find_prime();
  find_factor();
  while (cin >> n) {
    for (long long i = (1); i < (n + 1); i += 1) {
      scanf("%d", &arr[i]);
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    int all = 1 << primes.size();
    for (long long i = (0); i < (n); i += 1) {
      for (long long j = (0); j < (all); j += 1) {
        if (dp[i][j] == -1) continue;
        for (long long k = (1); k < (MAXV); k += 1) {
          int bit = bm[k];
          if (bit & j) continue;
          if (dp[i + 1][j | bit] == -1 ||
              dp[i + 1][j | bit] > dp[i][j] + abs(arr[i + 1] - k)) {
            dp[i + 1][j | bit] = dp[i][j] + abs(arr[i + 1] - k);
            corr[i + 1][j | bit] = k;
            pre[i + 1][j | bit] = j;
          }
        }
      }
    }
    int small = -1;
    int from = -1;
    for (long long i = (0); i < (all); i += 1) {
      if (dp[n][i] == -1) continue;
      if (small == -1 || dp[n][i] < small) {
        small = dp[n][i];
        from = i;
      }
    }
    int res[MAXN];
    for (long long i = (n); i > (0); i -= 1) {
      res[i] = corr[i][from];
      from = pre[i][from];
    }
    for (long long i = (1); i < (n + 1); i += 1) {
      printf("%d ", res[i]);
    }
    puts("");
  }
  return 0;
}