#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
bool is_prime[61];
vector<int> prime;
int n, up, a[105], v[61], dp[105][1 << 17];
int pre[100][1 << 17];
void get_prime() {
  memset(is_prime, true, sizeof(is_prime));
  is_prime[1] = false;
  for (int i = 2; i <= 60; i++) {
    if (!is_prime[i]) continue;
    prime.push_back(i);
    for (int j = i * 2; j <= 60; j += i) is_prime[j] = false;
  }
}
int main() {
  get_prime();
  up = 1 << (prime.size());
  memset(dp, inf, sizeof(dp));
  memset(pre, -1, sizeof(pre));
  for (int i = 1; i <= 60; i++) {
    int x = 0;
    for (int j = 0; j < prime.size(); j++) {
      if (i % prime[j] == 0) x |= 1 << j;
    }
    v[i] = x;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < up; j++) {
      for (int k = 1; k <= 60; k++) {
        if ((j & v[k]) == 0) {
          if (dp[i][j] + abs(k - a[i + 1]) < dp[i + 1][j | v[k]]) {
            pre[i + 1][j | v[k]] = j;
            dp[i + 1][j | v[k]] = dp[i][j] + abs(k - a[i + 1]);
          }
        }
      }
    }
  }
  int item = 0;
  for (int i = 0; i < up; i++)
    if (dp[n][i] < dp[n][item]) item = i;
  int cur = item, p = item, op = n;
  vector<int> ans;
  while (pre[op][cur] != -1) {
    cur = pre[op][cur];
    int xr = cur ^ p, g = -1;
    for (int i = 1; i <= 60; i++) {
      if (v[i] == xr) {
        if (g == -1 || abs(a[op] - g) > abs(a[op] - i)) g = i;
      }
    }
    ans.push_back(g);
    p = cur;
    op--;
  }
  for (int i = ans.size() - 1; i >= 0; i--) printf("%d ", ans[i]);
  puts("");
  return 0;
}
