#include <bits/stdc++.h>
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
int v[100], mask[60], dp[100][1 << 17], print[100][1 << 16], n;
bitset<60> pri;
void primos() {
  memset(mask, (0), sizeof(mask));
  pri.set();
  int con = -1;
  for (int i = 2; i < 57; i++) {
    if (pri[i]) {
      con++;
      for (int j = i + i; j < 57; j += i) {
        mask[j] |= (1 << con);
        pri[j] = 0;
      }
      mask[i] |= (1 << con);
    }
  }
}
int first(int pos, int mascara) {
  if (pos == n) return 0;
  if (dp[pos][mascara] != -1) return dp[pos][mascara];
  int mini = INT_MAX, par;
  for (int i = 1; i < 57; i++) {
    if ((mask[i] & mascara) == 0) {
      par = abs(v[pos] - i) + first(pos + 1, (mask[i] | mascara));
      if (mini > par) {
        mini = par;
        print[pos][mascara] = i;
      }
    }
  }
  dp[pos][mascara] = mini;
  return mini;
}
void imprime(int pos, int mascara) {
  if (pos == n) return;
  cout << print[pos][mascara] << ' ';
  imprime(pos + 1, mascara | mask[print[pos][mascara]]);
}
int main() {
  cin >> n;
  primos();
  for (int i = 0; i < n; i++) cin >> v[i];
  memset(dp, (-1), sizeof(dp));
  first(0, 0);
  imprime(0, 0);
  return 0;
}
