#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int INF = 0x3f3f3f3f;
int nxt[N][1 << 11], dp[N][1 << 11], n, ansx[N];
pair<int, int> v[N];
vector<int> primes;
bool isp(int x) {
  if (x == 1) return false;
  for (int j = 2; j * j <= x; j++)
    if (x % j == 0) return false;
  return true;
}
int f(int u, int pr) {
  if (u == n) return 0;
  if (__builtin_popcount(pr) == 10) {
    int rx = 0;
    for (int j = 10; j < primes.size() && u + j - 10 < n; j++)
      rx += abs(v[u + j - 10].first - primes[j]);
    return rx;
  }
  int &ret = dp[u][pr];
  if (ret != -1) return ret;
  ret = INF;
  for (int i = 1; i < N; i++) {
    int ux = 0;
    bool ok = 1;
    for (int j = 0; j < primes.size() && i >= primes[j]; j++)
      if (i % primes[j] == 0) {
        ux |= 1 << j;
        if (j >= 10) {
          ok = false;
          break;
        }
      }
    if (!ok) continue;
    if ((ux & pr) == 0) {
      int fx = f(u + 1, pr | ux) + abs(i - v[u].first);
      if (fx < ret) {
        ret = fx;
        nxt[u][pr] = i;
      }
    }
  }
  return ret;
}
int main(void) {
  ios::sync_with_stdio(false);
  for (int i = 2; primes.size() < 100; i++) {
    if (isp(i)) {
      primes.push_back(i);
    }
  }
  cin >> n;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v, v + n);
  memset(dp, -1, sizeof dp);
  int ans = f(0, 0);
  int x = 0, y = 0, pr = 0, nx = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (__builtin_popcount(pr) == 10) break;
    int u = nxt[i][pr];
    ansx[v[i].second] = u;
    int ux = 0;
    for (int j = 0; j < primes.size() && u >= primes[j]; j++)
      if (u % primes[j] == 0) ux |= 1 << j;
    pr |= ux;
  }
  for (int j = 10; i < n; j++) {
    ansx[v[i].second] = primes[j];
    i++;
  }
  for (int i = 0; i < n; i++) cout << ansx[i] << " ";
  cout << endl;
  return 0;
}
