#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int INF = (1 << 30) - 1;
const long double EPS = 1e-9;
void ML(const bool v) {
  if (v) return;
  int *ass;
  for (;;) {
    ass = new int[2500000];
    for (int i = 0; i < 2500000; i++) ass[i] = rand();
  }
}
void TL(const bool v) {
  if (v) return;
  for (;;) cout << rand() % (rand() % 1000) << endl;
}
void PE(const bool v) {
  if (v) return;
  for (int i = 0; i < 10000; i++) printf("%c", rand() % 256);
  exit(0);
}
const int MX = 60;
int a[105];
int n;
int ps[18];
int pn = 0;
int divs_msk[MX];
void pre() {
  bool was[MX];
  memset(was, false, sizeof(was));
  for (int i = 2; i < MX; i++)
    if (!was[i]) {
      ps[pn++] = i;
      for (int j = i; j < MX; j += i) was[j] = true;
    }
  for (int i = 1; i < MX; i++) {
    for (int j = 0; j < pn; j++)
      if (0 == i % ps[j]) divs_msk[i] = (divs_msk[i] | (1 << (j)));
  }
}
void LoAd() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
}
int sv[105][(1 << 18) + 5];
int nxt[105][(1 << 18) + 5];
int go(const int pos, const int msk) {
  if (pos == n) return 0;
  int nmsk = 0;
  int &res = sv[pos][msk];
  if (-1 != res) return res;
  res = INF;
  for (int i = 1; i < MX; i++)
    if (0 == (msk & divs_msk[i])) {
      int tmp = abs(i - a[pos]) + go(pos + 1, msk | divs_msk[i]);
      if (tmp < res) {
        res = tmp;
        nxt[pos][msk] = i;
      }
    }
  return res;
}
void print(const int pos, const int msk) {
  int i = nxt[pos][msk];
  if (-1 != i) {
    printf("%d ", i);
    print(pos + 1, msk | divs_msk[i]);
  }
}
void SoLvE() {
  memset(sv, -1, sizeof(sv));
  memset(nxt, -1, sizeof(nxt));
  int res = go(0, 0);
  ;
  print(0, 0);
}
int main() {
  srand((int)time(NULL));
  pre();
  LoAd();
  SoLvE();
  return 0;
}
