#include <bits/stdc++.h>
using namespace std;
int a[109];
bool flag[100];
int prime[100], r[100];
int x[20], tol, res;
const int maxn = (1 << 17) + 100;
int dp[109][maxn];
int pre[109][maxn];
int b[100];
void init() {
  int i, j;
  for (i = 1; i <= 60; i++) {
    int u = 0;
    if (prime[i] == 1)
      r[i] = 0;
    else {
      for (j = 1; j <= res; j++) {
        if (prime[i] % x[j] == 0) u += (1 << (j - 1));
      }
    }
    r[i] = u;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int i, j, k;
  for (i = 1; i <= 60; i++) flag[i] = true;
  tol = 0;
  memset(dp, -1, sizeof(dp));
  res = 0;
  for (i = 2; i <= 59; i++) {
    if (flag[i]) {
      x[++res] = i;
      for (j = i + i; j <= 60; j += i) flag[j] = false;
    }
  }
  for (i = 1; i <= 30; i++) {
    prime[++tol] = i;
  }
  for (i = 31; i <= 59; i++) prime[++tol] = i;
  init();
  dp[0][0] = 0;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    for (j = 0; j < maxn; j++)
      if (dp[i - 1][j] != -1) {
        for (k = 60; k >= 1; k--) {
          if ((r[k] & j) == 0) {
            if (dp[i][r[k] ^ j] == -1 ||
                dp[i][r[k] ^ j] > dp[i - 1][j] + abs(a[i] - prime[k])) {
              dp[i][r[k] ^ j] = dp[i - 1][j] + abs(a[i] - prime[k]);
              pre[i][r[k] ^ j] = k;
            }
          }
        }
      }
  }
  int ans = 29000000, which = -1;
  for (i = 0; i < maxn; i++)
    if (dp[n][i] != -1) {
      if (ans > dp[n][i]) ans = dp[n][i], which = i;
    }
  int y = 0;
  i = n;
  j = which;
  while (i) {
    b[++y] = pre[i][j];
    j = (j ^ r[pre[i][j]]);
    i--;
  }
  for (i = y; i >= 1; i--) {
    if (i == y)
      printf("%d", b[i]);
    else
      printf(" %d", b[i]);
  }
  puts("");
  return 0;
}
