#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
const int maxm = 4e5 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
int n, cnt, ed, mn = inf, ans;
int f[maxn][1 << 16], fa[maxn][1 << 16];
int v[maxn], q[maxn], a[60];
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
inline int cal(int x) {
  int sum = 0;
  for (int i = 0; i < 16; i++)
    if (x % p[i] == 0) sum += (1 << i);
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i < 59; i++) a[i] = cal(i);
  memset(f, -1, sizeof(f));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  ed = (1 << 16) - 1;
  f[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= ed; j++)
      if (f[i][j] != -1) {
        for (int k = 1; k < 59; k++) {
          int to = j + a[k], t = f[i][j] + abs(k - v[i + 1]);
          if (((j | a[k]) == to) && (t < f[i + 1][to] || f[i + 1][to] == -1)) {
            f[i + 1][to] = t;
            fa[i + 1][to] = k;
          }
        }
      }
  for (int i = 0; i <= ed; i++) {
    if (f[n][i] < mn && f[n][i] != -1) {
      ans = i;
      mn = f[n][i];
    }
  }
  for (int i = n; i; i--) {
    q[i] = fa[i][ans];
    ans -= a[q[i]];
  }
  for (int i = 1; i <= n; i++) cout << q[i] << " ";
  return ~~(0 - 0);
}
