#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
inline void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << "}\n";
}
template <typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}\n";
}
const int N = 101, M = 60;
int n, A[N], id[M], res[N], dp[N][1 << 17], trace[N][1 << 17];
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
inline bool getbit(int x, int i) { return (x >> i) & 1; }
inline void clearbit(int &x, int i) { x &= (~(1 << i)); }
inline void setbit(int &x, int i) { x |= (1 << i); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0, _n = (17); i < _n; ++i) id[prime[i]] = i;
  int s, val;
  fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(int), 2e9);
  fill(dp[0], dp[0] + sizeof(dp[0]) / sizeof(int), 0);
  for (int i = 1, _n = (n); i <= _n; ++i) cin >> A[i];
  for (int i = 1, _n = (n); i <= _n; ++i) {
    for (int x = 1, _n = (M); x <= _n; ++x) {
      s = 0;
      val = x;
      for (int j = 2; j * j <= val; ++j) {
        while (val % j == 0) {
          val /= j;
          setbit(s, id[j]);
        }
      }
      if (val > 1) setbit(s, id[val]);
      for (int mask = 0, _n = (1 << 17); mask < _n; ++mask) {
        if ((s & mask) == s) {
          if (dp[i - 1][s ^ mask] + abs(A[i] - x) < dp[i][mask]) {
            dp[i][mask] = dp[i - 1][s ^ mask] + abs(A[i] - x);
            trace[i][mask] = x;
          }
        }
      }
    }
  }
  int msk = (1 << 17) - 1;
  for (int i = (n); i > 0; --i) {
    val = res[i] = trace[i][msk];
    s = 0;
    for (int j = 2; j * j <= val; ++j) {
      while (val % j == 0) {
        val /= j;
        setbit(s, id[j]);
      }
    }
    if (val > 1) setbit(s, id[val]);
    msk ^= s;
  }
  for (int i = 1, _n = (n); i <= _n; ++i) cout << res[i] << ' ';
  return 0;
}
