#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = acos(-1);
const int N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 2e18;
long long xyp(long long x, long long y) {
  if (y == 0) return 1LL;
  if (y == 1) return x;
  if (y % 2) {
    long long p = xyp(x, y - 1);
    return (x * p) % mod;
  }
  long long p = xyp(x, y / 2);
  return (p * p) % mod;
}
long long add(long long a, long long b) {
  return (a % mod + b % mod + mod) % mod;
}
long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long mul(long long a, long long b) {
  return ((a % mod) * (b % mod) + mod) % mod;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> second) {
  os << "{ ";
  for (auto s : second) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream& operator<<(ostream& os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ")";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int factormask[59], a[105], n;
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
void pre() {
  for (int i = 1; i < 59; i++) {
    factormask[i] = 0;
    for (int j = 0; j < 16; j++) {
      if (i % p[j] == 0) {
        factormask[i] |= (1 << j);
      }
    }
  }
}
int DP[101][1 << 16], b[101][1 << 16];
int calc(int i, int mask) {
  if (i == 0) return 0;
  if (DP[i][mask] != -1) return DP[i][mask];
  DP[i][mask] = calc(i - 1, mask) + abs(a[i] - 1);
  b[i][mask] = 1;
  for (int j = 2; j < 59; j++) {
    if ((mask & factormask[j]) != factormask[j]) continue;
    int cur = calc(i - 1, mask ^ factormask[j]) + abs(a[i] - j);
    if (cur < DP[i][mask]) {
      DP[i][mask] = cur;
      b[i][mask] = j;
    }
  }
  return DP[i][mask];
}
int main() {
  pre();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(25);
  {
    memset(DP, -1, sizeof(DP));
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int fullmask = (1 << 16) - 1;
    calc(n, fullmask);
    vector<int> b_out(n + 1);
    for (int i = n, mask = fullmask; i > 0; i--) {
      int cur = b[i][mask];
      b_out[i] = cur;
      mask ^= factormask[cur];
    }
    for (int i = 1; i <= n; i++) cout << b_out[i] << " ";
    cout << endl;
  }
  return 0;
}
