#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, a[100];
int memo[101][1 << 16], memo_b[101][1 << 16], memo_f[60];
const int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int factorize(int x) {
  if (memo_f[x] != -1) return memo_f[x];
  int r = 0;
  for (int i = 0; i < int(16); i++) {
    if (x % p[i] == 0) {
      r |= 1 << i;
    }
  }
  return memo_f[x] = r;
}
int rec(int c, int set) {
  if (c == 0) return 0;
  if (memo[c][set] != -1) return memo[c][set];
  int mi = inf;
  for (int i = 1; i <= 2 * a[c - 1] - 1; i++) {
    int f = factorize(i);
    if ((set & f) == f) {
      int k = rec(c - 1, set ^ f) + abs(a[c - 1] - i);
      if (mi > k) {
        mi = k;
        memo_b[c][set] = i;
      }
    }
  }
  return memo[c][set] = mi;
}
int main() {
  memset(memo, -1, sizeof(memo));
  memset(memo_b, -1, sizeof(memo_b));
  memset(memo_f, -1, sizeof(memo_f));
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  rec(n, (1 << 16) - 1);
  int b[100] = {};
  int set = (1 << 16) - 1;
  for (int i = n; i > 0; i--) set -= factorize(b[i - 1] = memo_b[i][set]);
  for (int i = 0; i < int(n); i++) cout << b[i] << " ";
  cout << endl;
}
