#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 6;
const int Log2 = 19;
const int inf = 1e9 + 7;
vector<int> ans;
int prime[10] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int outer[7] = {31, 37, 41, 43, 47, 53, 59};
bool dd[N];
int n, a[N], dp[103][1048][9];
bool chk(int n, int state) {
  for (int i = 0; i < 10; i++) {
    if (n % prime[i] == 0) {
      if ((state & (1 << i))) return 0;
    }
  }
  return 1;
}
int oper(int n, int state) {
  int res = state;
  for (int i = 0; i < 10; i++) {
    if (n % prime[i] == 0) res |= (1 << i);
  }
  return res;
}
int f(int pos, int state, int out) {
  if (pos > n) return 0;
  if (dp[pos][state][out] != -1) return dp[pos][state][out];
  int ans = inf;
  for (int i = 1; i <= 60; i++) {
    if (chk(i, state) && !dd[i]) {
      int res = oper(i, state);
      ans = min(ans, abs(a[pos] - i) + f(pos + 1, res, out));
    }
  }
  if (out < 7)
    ans = min(ans, abs(a[pos] - outer[out]) + f(pos + 1, state, out + 1));
  return dp[pos][state][out] = ans;
}
void Trace(int pos, int state, int out) {
  if (pos > n) return;
  for (int i = 1; i <= 60; i++) {
    if (chk(i, state) && !dd[i]) {
      int res = oper(i, state);
      if (f(pos, state, out) == abs(a[pos] - i) + f(pos + 1, res, out)) {
        ans.push_back(i);
        Trace(pos + 1, res, out);
        return;
      }
    }
  }
  if (out < 7 && f(pos, state, out) ==
                     abs(a[pos] - outer[out]) + f(pos + 1, state, out + 1))
    ans.push_back(outer[out]), Trace(pos + 1, state, out + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("tst"
            ".inp",
            "r")) {
    freopen(
        "tst"
        ".inp",
        "r", stdin);
  }
  for (int i = 0; i < 7; i++) dd[outer[i]] = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  Trace(1, 0, 0);
  for (auto i : ans) cout << i << " ";
}
