#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
long long dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
bool test = 0;
bool isprime(long long n) {
  for (long long i = 2; i <= sqrt(n); ++i)
    if (n % i == 0) return false;
  return true;
}
const long long N = 1e2 + 5;
long long n, a[N];
long long cache[105][262145];
vector<long long> prime = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                           29, 31, 37, 41, 43, 47, 53, 59};
vector<long long> mask2(60);
long long dp(long long idx, long long mask) {
  if (idx == n) {
    cache[idx][mask] = 0;
    return 0;
  }
  long long &ans = cache[idx][mask];
  if (ans != -1) return ans;
  ans = abs(a[idx] - 1) + dp(idx + 1, mask);
  for (long long i = 2; i <= 59; ++i) {
    if ((mask & mask2[i]) == 0) {
      ans = min(ans, abs(a[idx] - i) + dp(idx + 1, mask | mask2[i]));
    }
  }
  return ans;
}
void dp1(long long idx, long long mask) {
  if (idx == n) return;
  if (cache[idx][mask] == abs(a[idx] - 1) + cache[idx + 1][mask]) {
    cout << 1 << " ";
    dp1(idx + 1, mask);
    return;
  }
  for (long long i = 2; i <= 59; ++i) {
    if ((mask & mask2[i]) == 0 and
        cache[idx][mask] == cache[idx + 1][mask | mask2[i]] + abs(a[idx] - i)) {
      cout << i << " ";
      dp1(idx + 1, mask | mask2[i]);
      return;
    }
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  memset(cache, -1, sizeof(cache));
  for (long long i = 2; i < 60; ++i) {
    long long x = 0;
    for (long long j = 0; j < 17; ++j)
      if (i % prime[j] == 0) x |= (1ll << j);
    mask2[i] = x;
  }
  dp(0, 0);
  dp1(0, 0);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  if (test) cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
