#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const double ZERO = 0;
const double DOUBLE_MAX = 1 / ZERO;
vector<vector<int> > fact(62);
int n;
vector<int> a(101);
vector<int> prim;
int dp[101][1 << 19];
int pr[65] = {0};
vector<int> sol(101);
int solve(int id, int mask) {
  if (id == n) {
    return 0;
  }
  if (dp[id][mask] != -1) return dp[id][mask];
  int res = a[id] - 1 + solve(id + 1, mask);
  sol[id] = 1;
  for (int i = 2; i < 58; i++) {
    int msk = mask;
    bool ok = 1;
    for (int j = 0; j < fact[i].size(); j++) {
      if (1 << pr[fact[i][j]] & mask) {
        ok = 0;
        break;
      }
      msk |= (1 << pr[fact[i][j]]);
    }
    if (!ok) continue;
    if (res > abs(a[id] - i) + solve(id + 1, msk)) {
      res = abs(a[id] - i) + solve(id + 1, msk);
    }
  }
  return dp[id][mask] = res;
}
void print(int id, int mask) {
  if (id == n) return;
  int res = (0x7fffffff), x, ms;
  for (int i = 1; i < 58; i++) {
    int msk = mask;
    bool ok = 1;
    for (int j = 0; j < fact[i].size(); j++) {
      if (1 << pr[fact[i][j]] & mask) {
        ok = 0;
        break;
      }
      msk |= (1 << pr[fact[i][j]]);
    }
    if (!ok) continue;
    if (id == n - 1) {
      if (abs(a[id] - i) < res) {
        res = abs(a[id] - i);
        x = i;
        ms = msk;
      }
    } else if (dp[id + 1][msk] != -1 &&
               dp[id + 1][msk] + abs(a[id] - i) < res) {
      res = abs(a[id] - i) + dp[id + 1][msk];
      x = i;
      ms = msk;
    }
  }
  cout << x << " ";
  print(id + 1, ms);
}
int main() {
  memset(dp, -1, sizeof dp);
  for (int i = 1; i < 62; i++) {
    int k = i, p = 2;
    while (k != 1) {
      while (k % p) p++;
      fact[i].push_back(p);
      while (k % p == 0) k /= p;
    }
  }
  int p[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29, 31,
             37, 39, 41, 43, 47, 51, 53, 57, 59, 61};
  prim = vector<int>(p, p + 21);
  for (int i = 0; i < prim.size(); i++) pr[prim[i]] = i;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(0, 0);
  print(0, 0);
  return 0;
}
