#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
int dp[101][1 << 18], n, a[111], man, ansd[111], loc[100];
vector<int> fact[100];
int rec(int i, int mask) {
  if (i == n) return 0;
  if (dp[i][mask] != 1000000000) return dp[i][mask];
  int dif = abs(a[i] - 1);
  int ans = rec(i + 1, mask) + dif;
  for (int j = 2; j <= 60; j++) {
    int k;
    for (k = 0; k < fact[j].size(); k++)
      if (mask & (1 << fact[j][k])) break;
    if (k != (int)fact[j].size()) continue;
    int d = abs(a[i] - j);
    if (d <= dif) {
      int msk = mask;
      for (k = 0; k < fact[j].size(); k++) msk = msk | (1 << fact[j][k]);
      ans = min(ans, rec(i + 1, msk) + d);
    }
  }
  return dp[i][mask] = ans;
}
void reccons(int i, int mask, int m) {
  if (i == n) return;
  int dif = abs(a[i] - 1);
  if (rec(i + 1, mask) == m - dif) {
    ansd[i] = 1;
    reccons(i + 1, mask, m - dif);
    return;
  }
  for (int j = 2; j <= 60; j++) {
    int k;
    for (k = 0; k < fact[j].size(); k++)
      if (mask & (1 << fact[j][k])) break;
    if (k != (int)fact[j].size()) continue;
    int d = abs(a[i] - j);
    if (d > dif) continue;
    int msk = mask;
    for (k = 0; k < fact[j].size(); k++) msk = msk | (1 << fact[j][k]);
    if (rec(i + 1, msk) == m - d) {
      ansd[i] = j;
      reccons(i + 1, msk, m - d);
      return;
    }
  }
}
int main() {
  int i, j, t;
  for (i = 2; i <= 60; i++) {
    for (j = 2; j < i; j++)
      if (i % j == 0) break;
    if (j == i) primes.push_back(i);
  }
  for (i = 0; i < 17; i++) loc[primes[i]] = i;
  for (i = 2; i <= 60; i++) {
    for (j = 0; j < 17; j++)
      if (i % primes[j] == 0) fact[i].push_back(j);
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i <= n; i++)
    for (j = 0; j < (1 << 17); j++) dp[i][j] = 1000000000;
  man = rec(0, 0);
  reccons(0, 0, man);
  for (i = 0; i < n; i++) printf("%d ", ansd[i]);
  printf("\n");
  return 0;
}
