#include <bits/stdc++.h>
using namespace std;
vector<int> prime;
int den[61];
const int INF = 1 << 30;
void gen() {
  for (int i = 2; i <= 120; ++i) {
    int ok = 1;
    for (int j = 2; j * j <= i; ++j)
      if (i % j == 0) ok = 0;
    if (ok) prime.push_back(i);
  }
  for (int i = 2; i < 59; ++i) {
    for (int j = 0; prime[j] <= i; ++j)
      if (i % prime[j] == 0) den[i] |= 1 << j;
  }
}
int dp[101][1 << 17];
pair<short, int> par[101][1 << 17];
int n;
int a[102];
void task() {
  ios_base::sync_with_stdio(0);
  fill(par[0], par[0] + 101 * (1 << 17), make_pair(-1, -1));
  fill(dp[0], dp[0] + 101 * (1 << 17), INF);
  gen();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < (1 << 17); ++j)
      if (dp[i][j] != INF) {
        for (int val = 1; val <= 60; ++val) {
          int ok = 1;
          if (den[val] & j) continue;
          int mask = j | den[val];
          if (ok && dp[i][j] + abs(val - a[i]) < dp[i + 1][mask]) {
            dp[i + 1][mask] = dp[i][j] + abs(val - a[i]);
            par[i + 1][mask] = {val, j};
          }
        }
      }
  int mask_ans = 0;
  for (int j = 0; j < (1 << 17); ++j)
    if (dp[n][j] < dp[n][mask_ans]) mask_ans = j;
  (void(1));
  vector<int> ans(n, 0);
  for (int i = n; i > 0; mask_ans = par[i][mask_ans].second, --i) {
    ans[i - 1] = par[i][mask_ans].first;
  }
  for (auto x : ans) cout << x << ' ';
}
int main() {
  task();
  return 0;
}
