#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res % mod;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const std::vector<std::pair<int, int>> moves{{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
inline int bitCount(long long x) { return __builtin_popcountll(x); }
inline long long highestOneBit(long long x) {
  return 1LL << (63 - __builtin_clzll(x | 1LL));
}
inline int binaryDigits(long long x) { return 64 - __builtin_clzll(x | 1LL); }
template <typename A>
string to_string(A* ptr) {
  stringstream ss;
  ss << "0x" << std::setw(16) << std::setfill('0') << std::hex
     << (uint64_t)(uintptr_t)ptr;
  return ss.str();
}
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
vector<int> prime = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                     29, 31, 37, 41, 43, 47, 53, 59};
vector<int> f(60);
void precalc() {
  for (int i = 1; i < 60; i++) {
    int msk = 0;
    for (int j = 0; j < 17; j++) {
      if (i % prime[j] == 0) msk |= (1 << j);
    }
    f[i] = msk;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  precalc();
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(1 << 16, vector<int>(n + 1, 1e9));
  for (int i = 0; i < 1 << 16; i++) dp[i][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 1 << 16; j++) {
      for (int k = 1; k < 59; k++) {
        if (f[k] & j)
          continue;
        else {
          dp[f[k] | j][i + 1] =
              min(dp[f[k] | j][i + 1], dp[j][i] + abs(k - a[i]));
        }
      }
    }
  }
  int msk = 0;
  for (int i = 0; i < 1 << 16; i++) {
    if (dp[msk][n] > dp[i][n]) {
      msk = i;
    }
  }
  vector<int> ans;
  for (int i = n - 1; i >= 0; i--) {
    for (int k = 1; k < 59; k++) {
      if ((msk & f[k]) != f[k]) continue;
      if (dp[msk][i + 1] == dp[msk ^ f[k]][i] + abs(k - a[i])) {
        ans.push_back(k);
        msk ^= f[k];
        break;
      }
    }
  }
  assert(((int)(ans).size()) == n);
  for (int i = n - 1; i >= 0; i--) cout << ans[i] << " \n"[i == 0];
}
