#include <bits/stdc++.h>
using namespace std;
bool criba[70];
int pcnt = 0;
int primes[70];
int mask[70];
void getprimes() {
  for (int i = 4; i <= 60; i += 2) {
    criba[i] = true;
  }
  for (int i = 3; i * i <= 60; i += 2)
    if (!criba[i])
      for (int j = i * i; j <= 60; j += i) criba[j] = true;
  for (int i = 2; i <= 60; i++)
    if (!criba[i]) primes[pcnt++] = i;
  return;
}
void getmasks() {
  for (int i = 1; i <= 60; i++) {
    for (int j = 0; j < pcnt; j++)
      if (i % primes[j] == 0) {
        mask[i] |= (1 << j);
      }
  }
  return;
}
int t, n;
int v[105];
int dp[105][(1 << 17)];
int soy[105][(1 << 17)];
int match[105][(1 << 17)];
void bwads(int idx, int msk) {
  if (!idx) return;
  bwads(idx - 1, match[idx][msk]);
  printf("%d ", soy[idx][msk]);
  return;
}
int main() {
  getprimes();
  getmasks();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << pcnt); j++) dp[i][j] = INT_MAX;
  for (int i = 1; i <= n; i++) {
    for (int val = 1; val <= 60; val++) {
      for (int j = 0; j < (1 << pcnt); j++) {
        if (j & mask[val]) continue;
        if (dp[i - 1][j] + abs(val - v[i]) < dp[i][j | mask[val]]) {
          dp[i][j | mask[val]] = dp[i - 1][j] + abs(val - v[i]);
          soy[i][j | mask[val]] = val;
          match[i][j | mask[val]] = j;
        }
      }
    }
  }
  int ans = INT_MAX;
  for (int j = 0; j < (1 << pcnt); j++) ans = min(ans, dp[n][j]);
  for (int j = 0; j < (1 << pcnt); j++)
    if (dp[n][j] == ans) {
      bwads(n, j);
      break;
    }
  return 0;
}
