#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <typename T>
void DBG(const char* name, T&& H) {
  cerr << name << " = " << H << ')' << '\n';
}
template <typename T, typename... Args>
void DBG(const char* names, T&& H, Args&&... args) {
  const char* NEXT = strchr(names + 1, ',');
  cerr.write(names, NEXT - names) << " = " << H << " |";
  DBG(NEXT + 1, args...);
}
const int mod = 1e9 + 7;
const int INF = 1e8;
const int maxN = 101;
const int maxM = (1LL << 17);
int n;
vector<int> a(maxN);
vector<int> prime = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                     29, 31, 37, 41, 43, 47, 53, 59};
vector<int> divisor(60);
vector<vector<int>> dp(maxN, vector<int>(maxM, -1));
vector<vector<int>> best(maxN, vector<int>(maxM, -1));
vector<int> ans;
int rec(int idx, int mask) {
  if (idx == n) return 0;
  if (dp[idx][mask] != -1) return dp[idx][mask];
  int ans = INF;
  int choice = 1;
  ans = rec(idx + 1, mask) + abs(a[idx] - 1);
  for (int i = 2; i < 60; i++) {
    if (mask & divisor[i]) continue;
    int newMask = (mask | divisor[i]);
    int res = rec(idx + 1, newMask) + abs(a[idx] - i);
    if (res < ans) {
      ans = res;
      choice = i;
    }
  }
  dp[idx][mask] = ans;
  best[idx][mask] = choice;
  return dp[idx][mask];
}
void buildAns(int idx, int mask) {
  if (idx == n) return;
  ans.push_back(best[idx][mask]);
  mask |= divisor[best[idx][mask]];
  buildAns(idx + 1, mask);
}
void Solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < 60; i++) {
    int x = i;
    int mask = 0;
    for (int j = 0; j < prime.size(); j++) {
      if (x % prime[j]) continue;
      mask |= (1LL << j);
      while ((x % prime[j]) == 0) {
        x /= prime[j];
      }
    }
    divisor[i] = mask;
  }
  rec(0, 0);
  buildAns(0, 0);
  for (auto i : ans) {
    cout << i << " ";
  }
  cout << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  while (tt--) {
    Solve();
  }
  return 0;
}
