#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n;
const int nMax = 100;
int A[nMax];
const int pMax = 58 + 1;
const int pszMax = 16;
bitset<pMax> isPrime;
int prime[pszMax];
int indexOf[pMax];
int divv[pMax];
void sieve() {
  isPrime.set();
  isPrime[0] = isPrime[1] = 0;
  int prime_idx = 0;
  for (int i = 2; i < pMax; i++) {
    if (!isPrime[i]) continue;
    prime[prime_idx] = i;
    indexOf[i] = prime_idx;
    prime_idx++;
    divv[i] = i;
    for (int j = i * i; j < pMax; j += i) isPrime[j] = 0, divv[j] = i;
  }
  assert(prime_idx == 16);
}
const int AiMax = 30 + 1;
int memo[nMax][(1 << pszMax)];
int memov[pMax][(1 << pszMax)];
vector<pair<int, int> > V[(1 << pszMax)];
int valid(int x, int mask) {
  int &nmask = memov[x][mask];
  if (nmask != -1) return nmask;
  nmask = mask;
  while (x != 1) {
    int pf = divv[x];
    if (mask & (1 << indexOf[pf])) {
      return nmask = -2;
    }
    x /= pf;
    nmask = nmask | (1 << indexOf[pf]);
  }
  return nmask;
}
void prepro() {
  for (int mask = 0; mask < (1 << pszMax); mask++) {
    for (int k = 1; k < pMax; k++) {
      int nmask = valid(k, mask);
      if (nmask != -2) V[mask].push_back(make_pair(nmask, k));
    }
  }
}
int rec(int i = 0, int mask = 0) {
  if (i == n) return 0;
  int &ret = memo[i][mask];
  if (ret != -1) return ret;
  ret = (1000000000);
  int tmp = max(1, 2 * A[i] - 2);
  int sz = V[mask].size();
  for (int j = 0; j < sz; j++) {
    int k = V[mask][j].second;
    int nmask = V[mask][j].first;
    if (k > tmp) break;
    ret = min(ret, rec(i + 1, nmask) + abs(A[i] - k));
  }
  return ret;
}
void trace(int i = 0, int mask = 0) {
  if (i == n) return;
  int ret = rec(i, mask);
  int tmp = max(1, 2 * A[i] - 2);
  int sz = V[mask].size();
  for (int j = 0; j < sz; j++) {
    int k = V[mask][j].second;
    int nmask = V[mask][j].first;
    if (k > tmp) break;
    int nw = rec(i + 1, nmask) + abs(A[i] - k);
    if (nw != ret) continue;
    printf("%d%c", k, " \n"[i == n - 1]);
    trace(i + 1, nmask);
    return;
  }
  assert(0);
}
int main() {
  read_file();
  sieve();
  memset(memov, -1, sizeof memov);
  prepro();
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    memset(memo, -1, sizeof memo);
    trace();
  }
}
