#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10, INF = (int)1e9;
int n, f[MAXN][1 << 16], pre[MAXN][1 << 16], g[MAXN], a[MAXN], p[MAXN], tot;
void Print(int first, int s) {
  if (first == 0) return;
  Print(first - 1, s ^ g[pre[first][s]]);
  printf("%d ", pre[first][s]);
}
int main() {
  for (int i = 2; i < 59; ++i) {
    for (int j = 1; j <= tot; ++j)
      if (i % p[j] == 0) g[i] |= 1 << (j - 1);
    if (!g[i]) g[i] = 1 << tot, p[++tot] = i;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < (1 << 16); ++j) {
      f[i][j] = INF;
      for (int k = 1; k < 59; ++k)
        if ((g[k] | j) == j) {
          int nf = f[i - 1][j ^ g[k]] + abs(a[i] - k);
          if (nf < f[i][j]) f[i][j] = nf, pre[i][j] = k;
        }
    }
  Print(n, (1 << 16) - 1);
  puts("");
  fclose(stdin);
  fclose(stdout);
  return 0;
}
