#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 25;
vector<int> calc_primes(int maxn, int &sz) {
  vector<int> primes;
  primes.push_back(2);
  for (int(n) = (3); (n) < (maxn); (n)++) {
    bool isprime = true;
    for (int(i) = (0); (i) < (primes.size()); (i)++) {
      int p = primes[i];
      if (p * p > n) break;
      if (n % p == 0) {
        isprime = false;
        break;
      }
    }
    if (isprime) primes.push_back(n);
  }
  vector<int> mask(maxn, 0);
  sz = primes.size();
  for (int(n) = (1); (n) < (maxn); (n)++) {
    for (int(i) = (0); (i) < (primes.size()); (i)++)
      if (n % primes[i] == 0) mask[n] |= 1 << i;
  }
  return mask;
}
int dp[105][1 << 18], route[105][1 << 18];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int(i) = (0); (i) < (n); (i)++) {
    int x;
    cin >> x;
    v[i] = make_pair(x, i);
  }
  sort(v.begin(), v.end());
  int maxn = 60;
  int sz;
  vector<int> M = calc_primes(maxn, sz);
  for (int(i) = (0); (i) < (n + 1); (i)++)
    for (int(j) = (0); (j) < (1 << sz); (j)++) dp[i][j] = INF;
  dp[0][0] = 0;
  route[0][0] = 2;
  for (int(i) = (0); (i) < (n); (i)++)
    for (int(mask) = (0); (mask) < (1 << sz); (mask)++)
      if (dp[i][mask] != INF) {
        {
          int num = 1;
          if (dp[i + 1][mask | M[num]] >= dp[i][mask] + abs(v[i].first - num)) {
            dp[i + 1][mask | M[num]] = dp[i][mask] + abs(v[i].first - num);
            route[i + 1][mask | M[num]] = num;
          }
        }
        for (int(num) = (route[i][mask] + 1); (num) < (maxn); (num)++)
          if ((mask & M[num]) == 0) {
            if (dp[i + 1][mask | M[num]] >=
                dp[i][mask] + abs(v[i].first - num)) {
              dp[i + 1][mask | M[num]] = dp[i][mask] + abs(v[i].first - num);
              route[i + 1][mask | M[num]] = num;
            }
          }
      }
  vector<int> ans(n);
  int x = 0;
  for (int(i) = (0); (i) < (1 << sz); (i)++)
    if (dp[n][x] > dp[n][i]) x = i;
  for (int(i) = (n + 1) - 1; (i) >= (1); (i)--) {
    int cur = route[i][x];
    x = x ^ M[cur];
    int index = v[i - 1].second;
    ans[index] = cur;
  }
  bool first = true;
  for (int(i) = (0); (i) < (ans.size()); (i)++) {
    if (first)
      first = false;
    else
      cout << " ";
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}
