#include <bits/stdc++.h>
using namespace std;
using namespace std;
int pre[50];
int dp[101][1 << 17];
int fa[101][1 << 17];
int a[105];
int son[60];
int q[100], top;
int main() {
  int cnt = 0;
  memset(dp, -1, sizeof(dp));
  memset(son, 0, sizeof(0));
  for (int i = 2; i < 60; i++) {
    int t = sqrt(i), j;
    for (j = 2; j <= t; j++) {
      if (i % j == 0) break;
    }
    if (j == t + 1) pre[cnt++] = i;
  }
  for (int i = 2; i < 60; i++) {
    for (int j = 0; j < cnt; j++) {
      if (i % pre[j] == 0) son[i] |= (1 << j);
    }
  }
  int n, t = 1 << cnt;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t; j++) {
      if (dp[i][j] == -1) continue;
      for (int k = 1; k < 60; k++) {
        if (son[k] & j) continue;
        int tmp = son[k] | j;
        int num = dp[i][j] + abs(a[i + 1] - k);
        if (dp[i + 1][tmp] == -1 || dp[i + 1][tmp] > num) {
          dp[i + 1][tmp] = num;
          fa[i + 1][tmp] = k;
        }
      }
    }
  }
  int ans = 2000000009, ansid = 0;
  for (int i = 0; i < t; i++) {
    if (dp[n][i] < ans && dp[n][i] != -1) {
      ans = dp[n][i];
      ansid = i;
    }
  }
  top = 0;
  for (int i = n; i > 0; i--) {
    q[top++] = fa[i][ansid];
    ansid = ansid ^ son[q[top - 1]];
  }
  for (int i = top - 1; i >= 0; i--) {
    printf("%d%c", q[i], i == 0 ? '\n' : ' ');
  }
  return 0;
}
