#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
vector<int> primes(int n) {
  vector<int> p(n + 1, 1);
  for (int i = 2; i * i <= n; ++i)
    if (p[i])
      for (int j = i * i; j <= n; j += i) p[j] = 0;
  vector<int> res;
  for (int i = 2; i <= n; ++i)
    if (p[i]) res.push_back(i);
  return res;
}
int a[128], b[128];
int dp[128][1 << 16];
int pr[128][1 << 16];
int bit[64];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<int> prime = primes(54);
  for (int i = 0; i < (int)(128); i++)
    for (int j = 0; j < (int)(1 << 16); j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < (int)(64); i++)
    for (int j = 0; j < (int)(16); j++)
      if (i % prime[j] == 0) bit[i] += (1 << j);
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(1 << 16); j++) {
      for (int k = 0; k < (int)(54); k++)
        if ((bit[k] & j) == 0)
          if (dp[i + 1][bit[k] | j] > dp[i][j] + abs(a[i] - k)) {
            dp[i + 1][bit[k] | j] = dp[i][j] + abs(a[i] - k);
            pr[i + 1][bit[k] | j] = k;
          }
    }
  int pos = 0;
  for (int i = 0; i < (int)(1 << 16); i++)
    if (dp[n][pos] > dp[n][i]) pos = i;
  vector<int> res;
  for (int i = n; i > 0; --i) {
    res.push_back(pr[i][pos]);
    int k = pr[i][pos];
    pos = pos - bit[k];
  }
  reverse((res).begin(), (res).end());
  for (int i = 0; i < (int)(res.size()); i++) {
    if (i > 0) cout << " ";
    cout << res[i];
  }
  cout << endl;
  return 0;
}
