#include <bits/stdc++.h>
using namespace std;
const int oo = 1e9 + 7;
int dp[111][1 << 18], tr[111][1 << 18], prime[111], lp, mark[111];
int getbit(int x, int pos) { return (x >> pos) & 1; }
int onbit(int x, int pos) { return (x + (1 << pos)); }
void init() {
  int nt[200];
  for (int i = (1), _b = (60); i <= _b; i++) nt[i] = 1;
  nt[1] = 0;
  for (int i = (2), _b = (10); i <= _b; i++) {
    if (nt[i] == 1) {
      int j = i;
      while (j < 60) {
        j += i;
        nt[j] = 0;
      }
    }
  }
  lp = -1;
  for (int i = (1), _b = (60); i <= _b; i++) {
    if (nt[i]) {
      lp++;
      prime[lp] = i;
    }
  }
  for (int i = (1), _b = (60); i <= _b; i++) mark[i] = 0;
  for (int i = (1), _b = (60); i <= _b; i++) {
    int t = 0;
    for (int j = (0), _b = (lp); j <= _b; j++) {
      if (i % prime[j] == 0) {
        t = onbit(t, j);
      }
    }
    mark[i] = t;
  }
}
int abS(int x) {
  if (x > 0) return x;
  return -x;
}
int main() {
  int n, a[111];
  cin >> n;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  init();
  int maxtt = (1 << 17) - 1;
  for (int i = (0), _b = (maxtt); i <= _b; i++) dp[0][i] = 0;
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int tt = (0), _b = (maxtt); tt <= _b; tt++) dp[i][tt] = oo;
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int val = (1), _b = (60); val <= _b; val++) {
      for (int tt = (0), _b = (maxtt); tt <= _b; tt++) {
        if ((mark[val] & tt) == 0) {
          int ttnew = tt + mark[val];
          int dpval = dp[i - 1][tt] + abS(val - a[i]);
          if (dpval < dp[i][ttnew]) {
            dp[i][ttnew] = dpval;
            tr[i][ttnew] = val;
          }
        }
      }
    }
  }
  int ret = 0;
  for (int tt = (0), _b = (maxtt); tt <= _b; tt++)
    if (dp[n][ret] > dp[n][tt]) ret = tt;
  int res[111];
  for (int i = (n), _b = (1); i >= _b; i--) {
    res[i] = tr[i][ret];
    ret -= mark[res[i]];
  }
  for (int i = (1), _b = (n); i <= _b; i++)
    printf("%d%c", res[i], i == n ? '\n' : ' ');
  return 0;
}
