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;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int inf = 2000000000;
const long long linf = 5000000000000000000;
const long double LDINF = 2e18;
template <typename T>
void print(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
}
template <typename T>
void print(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
}
template <typename T>
void print(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
    cout << '\n';
  }
}
template <typename T>
void input(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(deque<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
template <typename T>
void input(vector<vector<T>>& a) {
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[i].size(); j++) cin >> a[i][j];
}
long long mod = 1190494759;
int mod1 = 1e9 + 7;
long long p = 233;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
vector<vector<long long>> mult(vector<vector<long long>>& A,
                               vector<vector<long long>>& B) {
  int n = A.size(), m = B[0].size();
  vector<vector<long long>> C(n, vector<long long>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < A[0].size(); k++) {
        C[i][j] += A[i][k] * B[k][j];
        C[i][j] %= mod;
      }
    }
  }
  return C;
}
vector<vector<long long>> BinPow(vector<vector<long long>>& A, long long n) {
  if (n == 1) {
    return A;
  }
  if (n % 2 == 1) {
    vector<vector<long long>> As = BinPow(A, n - 1);
    return mult(A, As);
  } else {
    vector<vector<long long>> As = BinPow(A, n / 2);
    return mult(As, As);
  }
}
bool isPrime(int n) {
  for (int i = 2; i < n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void solve() {
  vector<int> prime;
  vector<int> step;
  int pos = 0;
  int n;
  cin >> n;
  vector<int> a(n);
  input(a);
  map<int, int> ma;
  for (int i = 2; i < 60; i++)
    if (isPrime(i)) {
      ma[i] = prime.size();
      prime.push_back(i);
    }
  vector<int> f(61, 0);
  for (int i = 2; i < 61; i++) {
    int n = i;
    int del = 2;
    while (n != 1) {
      while (n % del == 0) {
        n /= del;
        f[i] |= (1 << ma[del]);
      }
      del++;
    }
  }
  vector<vector<int>> dp(n + 1, vector<int>(1 << 17, inf));
  for (int i = 0; i < 1 << 17; i++) {
    dp[0][i] = 0;
  }
  vector<vector<int>> p(n + 1, vector<int>(1 << 17, -1));
  for (int i = 1; i <= n; i++) {
    for (int b = 1; b <= 60; b++) {
      int d = (~f[b]) & ((1 << 17) - 1);
      int val = d;
      for (; val > 0; val = (val - 1) & (d)) {
        if (dp[i][val | f[b]] > dp[i - 1][val] + abs(b - a[i - 1])) {
          dp[i][val | f[b]] =
              min(dp[i][val | f[b]], dp[i - 1][val] + abs(b - a[i - 1]));
          p[i][val | f[b]] = b;
        }
      }
      dp[i][0 | f[b]] = min(dp[i][0 | f[b]], dp[i][0] + abs(b - a[i - 1]));
    }
  }
  int ans = 2e9;
  int nowi = -1, nowj = -1;
  for (int j = 0; j < 1 << 17; j++) {
    if (dp[n][j] == inf) continue;
    if (ans > dp[n][j]) {
      ans = min(ans, dp[n][j]);
      nowi = n, nowj = j;
    }
  }
  vector<int> ans2;
  while (true) {
    if (nowi == 0) break;
    int b = p[nowi][nowj];
    ans2.push_back(b);
    nowi--;
    nowj ^= f[b];
  }
  reverse((ans2).begin(), (ans2).end());
  print(ans2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tst = 1;
  while (tst--) solve();
}