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>
const long long N = 1000006;
using namespace std;
const long long MOD = 1000000007LL;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T power(T x, T y, long long m = MOD) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % m;
    y >>= 1LL;
    x = (x * x) % m;
  }
  return ans % m;
}
vector<long long> primes = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                            29, 31, 37, 41, 43, 47, 53, 59};
long long pl[105], siz;
void pre() {
  siz = primes.size();
  for (long long(i) = (2); i < (62); i++) {
    long long val = 0;
    for (long long(j) = (0); j < (siz); j++) {
      if (i % primes[j] == 0) {
        val |= (1 << j);
      }
    }
    pl[i] = val;
  }
}
long long a[N];
long long dp[105][(1 << 17) + 5], last[105][(1 << 17) + 5];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, 55, sizeof(dp));
  pre();
  long long n;
  cin >> n;
  for (long long(i) = (1); i < (n + 1); i++) cin >> a[i];
  for (long long(i) = (0); i < ((1 << siz)); i++) dp[0][i] = 0;
  for (long long(i) = (1); i < (n + 1); i++) {
    for (long long(k) = (1); k < (60); k++) {
      long long x = (~pl[k]) & ((1 << siz) - 1);
      for (long long s = x;; s = (s - 1) & x) {
        if (dp[i - 1][s] + abs(a[i] - k) < dp[i][s | pl[k]]) {
          dp[i][s | pl[k]] = dp[i - 1][s] + abs(a[i] - k);
          last[i][s | pl[k]] = k;
        }
        if (s == 0) break;
      }
    }
  }
  long long mini = 1000111000111000111LL, val;
  for (long long(i) = (0); i < ((1 << siz)); i++) {
    if (dp[n][i] < mini) {
      val = i;
      mini = dp[n][i];
    }
  }
  vector<long long> v;
  for (long long i = n; i >= 1; i--) {
    v.emplace_back(last[i][val]);
    val &= ~pl[last[i][val]];
  }
  reverse(v.begin(), v.end());
  for (auto i : v) cout << i << " ";
}