#include <bits/stdc++.h>
using namespace std;
const int MaxN = 110;
const int inf = 1e9;
inline int myabs(int x) { return x < 0 ? -x : x; }
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
bool np[65];
vector<int> P;
void eratosten(void) {
  for (int x = 2; x <= 60; ++x)
    if (!np[x]) {
      P.push_back(x);
      for (int y = 2; x * y <= 60; ++y) np[x * y] = true;
    }
}
int dp[MaxN][(1 << 17) + 10];
int N, a[MaxN], idx[MaxN];
bool ok[MaxN][MaxN];
vector<int> cand[(1 << 17) + 10], nmask[(1 << 17) + 10];
vector<int> ans;
bool cmpf(int i, int j) { return a[i] < a[j]; }
int f(int i, int mask) {
  if (i == N) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  if (i < N - 18) return dp[i][mask] = f(i + 1, mask) + myabs(a[i] - 1);
  int ret = inf;
  for (int j = 0; j < cand[mask].size(); ++j) {
    int x = cand[mask][j];
    ret = min(ret, f(i + 1, nmask[mask][j]) + myabs(a[i] - x));
  }
  return dp[i][mask] = ret;
}
void rec(int i, int mask) {
  if (i == N) return;
  int ret = f(i, mask);
  if (i < N - 17) {
    ans.push_back(1);
    rec(i + 1, mask);
    return;
  }
  for (int j = 0; j < cand[mask].size(); ++j) {
    int x = cand[mask][j];
    if (ret == f(i + 1, nmask[mask][j]) + myabs(a[i] - x)) {
      ans.push_back(x);
      rec(i + 1, nmask[mask][j]);
      return;
    }
  }
}
void init(void) {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < N; ++i) idx[i] = i;
  sort(idx, idx + N, cmpf);
  sort(a, a + N);
  for (int x = 1; x <= 60; ++x)
    for (int i = 0; i < P.size(); ++i)
      if (gcd(x, P[i]) == 1) ok[x][P[i]] = true;
  for (int mask = 0; mask < (1 << (int)P.size()); ++mask)
    for (int x = 1; x <= 60; ++x) {
      bool flag = false;
      int nm = mask;
      for (int j = 0; j < P.size(); ++j)
        if (!ok[x][P[j]] && (mask & (1 << j)) != 0) {
          flag = true;
          break;
        }
      if (!flag) {
        cand[mask].push_back(x);
        for (int j = 0; j < P.size(); ++j)
          if (!ok[x][P[j]]) nm |= 1 << j;
        nmask[mask].push_back(nm);
      }
    }
}
int res[MaxN];
int main(void) {
  eratosten();
  init();
  rec(0, 0);
  for (int i = 0; i < ans.size(); ++i) res[idx[i]] = ans[i];
  for (int i = 0; i < N; ++i) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
