#include <bits/stdc++.h>
using namespace std;
int N;
int prems[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int dp[100][1 << 17];
int tab[100];
int truc[61][3];
char vu[100][1 << 17];
int dynMin(int pos, int used) {
  if (pos == N) return 0;
  if (vu[pos][used]) return dp[pos][used];
  vu[pos][used] = 1;
  int& vc = dp[pos][used];
  vc = tab[pos] - 1 + dynMin(pos + 1, used);
  for (int i = 2; i < 60; i++) {
    int a = truc[i][0];
    int b = truc[i][1];
    int c = truc[i][2];
    if ((used & a) || (used & b) || (used & c)) continue;
    vc = min(vc, abs(i - tab[pos]) + dynMin(pos + 1, used | a | b | c));
  }
  return vc;
}
int main() {
  scanf("%d", &N);
  for (int i = 2; i < 60; i++) {
    int cnt = 0;
    for (int j = 0; j < 17; j++)
      if (i % prems[j] == 0) truc[i][cnt++] = 1 << j;
  }
  for (int i = 0; i < N; i++) {
    scanf("%d", &tab[i]);
  }
  dynMin(0, 0);
  int used = 0;
  for (int pos = 0; pos < N; pos++) {
    int best = tab[pos] - 1 + dynMin(pos + 1, used);
    int res = 1;
    for (int i = 2; i < 60; i++) {
      int a = truc[i][0];
      int b = truc[i][1];
      int c = truc[i][2];
      if ((used & a) || (used & b) || (used & c)) continue;
      int val = abs(i - tab[pos]) + dynMin(pos + 1, used | a | b | c);
      if (val < best) {
        best = val;
        res = i;
      }
    }
    printf("%d ", res);
    used |= truc[res][0] | truc[res][1] | truc[res][2];
  }
  putchar('\n');
  return 0;
}
