#include <bits/stdc++.h>
using namespace std;
const int inf = 1073741823;
const int maxint = 0x7fffffff;
const long long INF = 1152921504606846976ll;
const long double eps = 1E-9;
const long double pi = acos(-1);
template <class T>
inline T _sqr(T a) {
  return (a * a);
}
template <class T>
inline T _abs(T a) {
  return (a >= 0 ? a : -a);
}
template <class T>
inline T _lbt(T a) {
  return (a & (a ^ (a - 1)));
}
template <class T>
inline T _max(T a, T b) {
  return (a > b ? a : b);
}
template <class T>
inline T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
inline T _smax(T a, T b, T c) {
  return _max(_max(a, b), c);
}
template <class T>
inline T _smin(T a, T b, T c) {
  return _min(_min(a, b), c);
}
template <class T>
inline T _sqrt(T a) {
  T b, c;
  for (b = sqrt(a), c = b - 2; c <= b + 2; c++)
    if (_sqr(c) <= a) b = c;
  return b;
}
template <class T>
inline T _pow(T a, T b, T c) {
  T d = 1;
  for (a %= c; b; b >>= 1, a = a * a % c)
    if (b & 1) d = d * a % c;
  return d;
}
int n, m, k, t, x, y, p, T;
int f[111][(1 << 12)][10], choice[111][(1 << 12)][10], a[111], b[111];
int zz[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int prime[] = {31, 37, 41, 43, 47, 53, 59};
int state[111], tt[111];
void Solution_Production() {
  scanf("%d", &n);
  for (int i = 1; i <= 60; i++) {
    for (int j = 0; j < 10; j++)
      if (i % zz[j] == 0) state[i] |= 1 << j;
  }
  for (int i = 1; i <= 60; i++) tt[i] = false;
  for (int i = 0; i < 7; i++) tt[prime[i]] = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 10); j++)
      for (int k = 0; k < 8; k++) f[i][j][k] = inf;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 10); j++)
      for (int k = 0; k < 8; k++) {
        if (k && f[i - 1][j][k - 1] + abs(prime[k - 1] - a[i]) < f[i][j][k]) {
          f[i][j][k] = f[i - 1][j][k - 1] + abs(prime[k - 1] - a[i]);
          choice[i][j][k] = prime[k - 1];
        }
        for (int o = 1; o <= 60; o++)
          if (!tt[o] && ((j & state[o]) == state[o])) {
            if (f[i - 1][j ^ state[o]][k] + abs(a[i] - o) < f[i][j][k]) {
              choice[i][j][k] = o;
              f[i][j][k] = f[i - 1][j ^ state[o]][k] + abs(a[i] - o);
            }
          }
      }
  int mx, my, ans = inf;
  for (int mask = 0; mask < (1 << 10); mask++)
    for (int j = 0; j < 8; j++)
      if (f[n][mask][j] < ans) {
        ans = f[n][mask][j];
        mx = mask;
        my = j;
      }
  for (int i = n; i >= 1; i--) {
    b[i] = choice[i][mx][my];
    if (tt[b[i]]) {
      my--;
    } else {
      mx ^= state[b[i]];
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", b[i]);
}
int main() {
  Solution_Production();
  return 0;
}
