#include <bits/stdc++.h>
using namespace std;
int n, a[110], p[110], v[1010], cnt, t, sta, ans = 1e9;
int dp[1 << 17][110], f[60], b[1 << 17][110], pre[1 << 17][110];
void work(int x, int s) {
  if (!x) return;
  work(x - 1, pre[s][x]);
  printf("%d ", b[s][x]);
}
int abss(int x) { return x >= 0 ? x : -x; }
void init() {
  for (int i = 2; i <= 53; i++) {
    if (!v[i]) p[++cnt] = i;
    for (int j = 1; j <= cnt && i * p[j] <= 53; j++) {
      v[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  }
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int s = 0; s < (1 << cnt); s++)
    for (int i = 1; i <= n; i++) dp[s][i] = 1e9;
  dp[0][0] = 0;
  for (int i = 1; i <= 58; i++) {
    for (int j = 1; j <= cnt; j++)
      if (i % p[j] == 0) f[i] |= (1 << (j - 1));
  }
  for (int i = 1; i <= n; i++) {
    for (int s = 0; s < (1 << cnt); s++) {
      for (int j = 1; j <= 58; j++)
        if ((s ^ f[j]) == (s | f[j])) {
          t = s | f[j];
          if (dp[t][i] > dp[s][i - 1] + abss(a[i] - j)) {
            dp[t][i] = min(dp[t][i], dp[s][i - 1] + abss(a[i] - j));
            b[t][i] = j;
            pre[t][i] = s;
          }
        }
      if (i == n && ans > dp[s][i]) sta = s;
    }
  }
  work(n, sta);
}
