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;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
const int N = 17;
const int M = 60;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mask[M];
  memset(mask, 0, sizeof mask);
  for (int i = 2; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (i % primes[j] == 0) {
        mask[i] |= (1 << j);
      }
    }
  }
  int dp[n][(1 << N)];
  int par[n][1 << N];
  int val[n][1 << N];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1ll << N); j++) dp[i][j] = INT_MAX;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < M; j++) {
      int x = (~mask[j]) & ((1 << N) - 1);
      int second = 0;
      do {
        dp[i][second | mask[j]] =
            min(dp[i][second | mask[j]],
                (int)((i >= 1 ? dp[i - 1][second] : 0) + abs(a[i] - j)));
        if (dp[i][second | mask[j]] ==
            ((i >= 1 ? dp[i - 1][second] : 0) + abs(a[i] - j))) {
          par[i][second | mask[j]] = second;
          val[i][second | mask[j]] = j;
        }
      } while (second = (second - 1) & x);
    }
  }
  int ans = INT_MAX;
  int Mask = 0;
  for (int j = 0; j < (1 << N); j++) {
    ans = min(ans, dp[n - 1][j]);
    if (ans == dp[n - 1][j]) Mask = j;
  }
  vector<int> seq;
  int idx = n - 1;
  while (idx >= 0) {
    seq.push_back(val[idx][Mask]);
    Mask = par[idx][Mask];
    idx--;
  }
  reverse(seq.begin(), seq.end());
  for (auto c : seq) cout << c << " ";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}