#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 60;
const int maxm = 17;
const long long INF = 1e18;
long long powmod(long long x, long long y) {
  long long t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int prim[maxm] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                  29, 31, 37, 41, 43, 47, 53, 59},
    a[105];
int mp[maxn], dp[105][1 << maxm], nxt[105][1 << maxm];
int val(int x) { return x > 0 ? x : -x; }
void output(int n, int y, int z) {
  if (!n) return;
  output(n - 1, nxt[n - 1][y], y);
  int x = dp[n][z] - dp[n - 1][y];
  if (mp[a[n] - x] == (y ^ z))
    cout << a[n] - x << " ";
  else
    cout << a[n] + x << " ";
}
int n, mark;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int(i) = (1); (i) < (n + 1); (i)++) cin >> a[i];
  for (int(i) = (0); (i) < (maxm); (i)++) mp[prim[i]] = (1 << i);
  for (int(i) = (2); (i) < (maxn); (i)++)
    if (!mp[i]) {
      int tmp = i;
      for (int(j) = (2); (j) < (i); (j)++)
        if (tmp % j == 0) {
          while (tmp % j == 0) tmp /= j;
          mp[i] += mp[j];
        }
    }
  memset((dp), (0xf), sizeof(dp)), mark = dp[0][0], dp[0][0] = 0;
  for (int(i) = (1); (i) < (n + 1); (i)++)
    for (int(j) = (1); (j) < (maxn); (j)++)
      for (int(k) = (0); (k) < (1 << maxm); (k)++) {
        if ((k & mp[j]) == mp[j])
          if (dp[i - 1][k ^ mp[j]] != mark) {
            int tmp = dp[i - 1][k ^ mp[j]] + val(j - a[i]);
            if (dp[i][k] > tmp) dp[i][k] = tmp, nxt[i][k] = (k ^ mp[j]);
          }
      }
  int minv = mark, sta, cur;
  for (int(i) = (0); (i) < (1 << maxm); (i)++)
    if (dp[n][i] < minv) minv = dp[n][i], cur = i, sta = nxt[n][i];
  output(n, sta, cur);
  return 0;
}
