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 = 4005;
vector<int> prime;
const int maxPrime = 60, _sz = sizeof(int) * 8;
int _bits[maxPrime / (2 * _sz) + 5];
inline bool isPrime(int n) {
  if (n == 2) return true;
  if (!(n & 1)) return false;
  n >>= 1;
  return (_bits[n / _sz] & (1 << (n % _sz))) == 0;
}
void sieve(int n = maxPrime) {
  memset(_bits, 0, sizeof(_bits));
  _bits[0] = 0;
  for (int i = 3; i * i <= n; i += 2)
    if (isPrime(i)) {
      for (int j = i * i; j <= n; j += 2 * i)
        _bits[(j >> 1) / _sz] |= (1 << ((j >> 1) % _sz));
    }
}
void getPrimes(vector<int> &pr, int n = maxPrime) {
  sieve(n);
  pr.clear();
  pr.push_back(2);
  for (int i = 3; i <= n; i += 2)
    if (isPrime(i)) pr.push_back(i);
}
vector<int> arr, ans;
int dp[105][1 << 17];
int num[60];
int solve(int n, int msk) {
  if (n < 0) return 0;
  int &ret = dp[n][msk];
  if (ret == -1) {
    ret = solve(n - 1, msk) + arr[n] - 1;
    for (int i = int(1); i < int(60); i++)
      if ((num[i] & msk) == 0) {
        ret = min(ret, solve(n - 1, msk | num[i]) + abs(arr[n] - i));
      }
  }
  return ret;
}
void back(int n, int msk) {
  if (n < 0) return;
  if (solve(n, msk) == solve(n - 1, msk) + arr[n] - 1) {
    ans[n] = 1;
    back(n - 1, msk);
    return;
  }
  for (int i = int(1); i < int(60); i++)
    if ((num[i] & msk) == 0) {
      if (solve(n, msk) == solve(n - 1, msk | num[i]) + abs(arr[n] - i)) {
        ans[n] = i;
        back(n - 1, msk | num[i]);
        return;
      }
    }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  getPrimes(prime);
  for (int i = int(1); i < int(60); i++) {
    num[i] = 0;
    for (int j = 0; j < int(int((prime).size())); j++)
      if (i % prime[j] == 0) num[i] |= 1 << j;
  }
  int n;
  cin >> n;
  ans = arr = vector<int>(n);
  for (int i = 0; i < int(n); i++) {
    cin >> arr[i];
  }
  memset(dp, -1, sizeof(dp));
  solve(n - 1, 0);
  back(n - 1, 0);
  int sum = 0;
  for (int i = 0; i < int(n); i++) {
    cout << ans[i] << " ";
    sum += abs(ans[i] - arr[i]);
  }
  return 0;
}