#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 150;
const int NP = 17;
int p[NP] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int f[1 << NP], nf[1 << NP], use[N][1 << NP];
int a[N];
int fac[N];
void update(int &a, int b) {
  if (b != -1 && (a == -1 || a > b)) {
    a = b;
  }
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int x = 1; x <= 60; x++) {
    for (int i = 0; i < NP; i++)
      if (x % p[i] == 0) fac[x] |= 1 << i;
  }
  memset(f, -1, sizeof f);
  f[0] = 0;
  for (int i = 0; i < n; i++) {
    memset(nf, -1, sizeof nf);
    for (int mask = 0; mask < (1 << NP); mask++)
      if (f[mask] != -1) {
        for (int x = 1; x <= 60; x++) {
          if ((mask & fac[x]) == 0) {
            int ex = nf[mask | fac[x]];
            update(nf[mask | fac[x]], f[mask] + abs(a[i + 1] - x));
            if (ex != nf[mask | fac[x]]) use[i + 1][mask | fac[x]] = x;
          }
        }
      }
    for (int mask = 0; mask < (1 << NP); mask++) f[mask] = nf[mask];
  }
  int ans = inf, ans_mask = 0;
  for (int mask = 0; mask < (1 << NP); mask++) {
    if (f[mask] != -1 && ans > f[mask]) {
      ans = f[mask];
      ans_mask = mask;
    }
  }
  int mask = ans_mask;
  vector<int> vals;
  for (int i = n; i > 0; i--) {
    vals.push_back(use[i][mask]);
    mask ^= fac[use[i][mask]];
  }
  reverse((vals).begin(), (vals).end());
  for (__typeof((vals).begin()) it = (vals).begin(); it != (vals).end(); it++)
    printf("%d ", *it);
  return 0;
}
