#include <bits/stdc++.h>
using namespace std;
const int N = 61;
const int SZ = 106;
const int INF = 2E9;
int res = INF;
vector<int> prime;
int dp[SZ][(1LL << (17))];
int t[SZ][(1LL << (17))];
int a[SZ];
bool f[N];
long long c[N];
int n;
void sieve() {
  f[1] = f[0] = true;
  for (int i = 2; i * i < N; ++i)
    if (f[i] == false)
      for (int j = i * i; j < N; j += i) f[j] = true;
  for (int i = 1; i < N; ++i)
    if (f[i] == false) prime.push_back(i);
}
void factorize(int n) {
  for (int i = 0; i < (int)prime.size(); ++i) {
    int fact = prime[i];
    if (n % fact == 0) c[n] |= (1LL << (i));
  }
}
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sieve();
  for (int i = 1; i < N; ++i) factorize(i);
  for (int i = 0; i <= n; ++i)
    for (int mask = 0; mask < (1LL << (17)); ++mask) dp[i][mask] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i)
    for (int mask = 0; mask < (1LL << (17)); ++mask)
      for (int k = 1; k <= 60; ++k)
        if ((mask & c[k]) == 0)
          if (dp[i][mask | c[k]] > dp[i - 1][mask] + abs(a[i] - k)) {
            dp[i][mask | c[k]] = dp[i - 1][mask] + abs(a[i] - k);
            t[i][mask | c[k]] = k;
          }
  int ans_mask = 0;
  for (int mask = 0; mask < (1LL << (17)); ++mask)
    if (res > dp[n][mask]) {
      res = dp[n][mask];
      ans_mask = mask;
    }
  vector<int> ans;
  while (n >= 1) {
    int tmp = t[n][ans_mask];
    ans.push_back(tmp);
    --n;
    ans_mask = ans_mask ^ c[tmp];
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < (int)ans.size(); ++i) cout << ans[i] << " ";
}
