#include <bits/stdc++.h>
using namespace std;
const int maxS = 100;
bitset<maxS + 1> ip;
vector<int> primes;
void sieve() {
  ip.set();
  ip[0] = ip[1] = 0;
  for (int i = 2; i * i <= maxS; i++)
    if (ip[i])
      for (int j = i * i; j <= maxS; j += i) ip[j] = 0;
  for (int i = 2; i <= maxS; ++i)
    if (ip[i]) primes.push_back(i);
}
int n, arr[102], memo[102][1 << 16], ans[102][1 << 16], nxt[102][1 << 16],
    ind[102], m[102];
int solve(int cur, int mask) {
  if (cur == n) return 0;
  int &ret = memo[cur][mask];
  if (~ret) return ret;
  ret = 1e9;
  for (int i = 1; i <= 58; ++i) {
    if ((m[i] & mask) != m[i]) continue;
    int res = abs(arr[cur] - i) + solve(cur + 1, mask ^ m[i]);
    if (res < ret) {
      ans[cur][mask] = i;
      nxt[cur][mask] = mask ^ m[i];
      ret = res;
    }
  }
  return ret;
}
int main() {
  sieve();
  for (int i = 0; i < 16; ++i) ind[primes[i]] = i;
  for (int i = 2; i <= 58; ++i) {
    int v = i;
    for (int j = 2; j * j <= v; ++j) {
      if (v % j == 0) m[i] |= (1 << ind[j]);
      while (v % j == 0) v /= j;
    }
    if (v > 1) m[i] |= (1 << ind[v]);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &arr[i]);
  memset(memo, -1, sizeof memo);
  solve(0, (1 << 16) - 1);
  for (int cur = 0, mask = (1 << 16) - 1; cur < n; ++cur) {
    cout << ans[cur][mask] << " ";
    mask = nxt[cur][mask];
  }
};
