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>
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
const int mod = 1000000007;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
template <typename T>
inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  bool first = true;
  os << "[";
  for (auto i : v) {
    if (!first) os << ", ";
    os << i;
    first = false;
  }
  return os << "]";
}
const int N = 101;
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int n, dp[N][(1 << 17) + 1], a[N], b[N], val[61], track[N][(1 << 17) + 1];
std::vector<int> factors[61];
int solve(int ind, int mask) {
  if (ind >= n) {
    return dp[ind][mask] = 0;
  }
  int& ans = dp[ind][mask];
  if (ans != -1) return ans;
  ans = solve(ind + 1, mask) + a[ind] - 1;
  for (int i = 2; i <= 59; ++i) {
    bool good = true;
    int newMask = mask;
    for (auto j : factors[i]) {
      if (mask & (1 << val[j])) {
        good = false;
        break;
      }
      newMask |= (1 << val[j]);
    }
    if (good) {
      smin(ans, solve(ind + 1, newMask) + abs(a[ind] - i));
    }
  }
  return ans;
}
void go(int ind, int mask) {
  if (ind >= n) return;
  if (dp[ind][mask] == dp[ind + 1][mask] + a[ind] - 1) {
    b[ind] = 1;
    go(ind + 1, mask);
    return;
  }
  for (int i = 2; i <= 59; ++i) {
    bool good = true;
    int newMask = mask;
    for (auto j : factors[i]) {
      if (mask & (1 << val[j])) {
        good = false;
        break;
      }
      newMask |= (1 << val[j]);
    }
    if (good and dp[ind][mask] == dp[ind + 1][newMask] + abs(a[ind] - i)) {
      b[ind] = i;
      go(ind + 1, newMask);
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int x = 0;
  for (int i = 2; i < 60; ++i) {
    if (factors[i].empty()) {
      val[i] = x++;
      for (int j = i; j < 60; j += i) {
        factors[j].push_back(i);
      }
    }
  }
  solve(0, 0);
  go(0, 0);
  for (int i = 0; i < n; ++i) {
    cout << b[i] << ' ';
  }
  return 0;
}