#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
vector<int> prime;
const int maxPrime = 60, _sz = sizeof(int) * 8;
int _bits[maxPrime / (2 * _sz) + 5];
inline bool isPrime(int n) {
  if (n == 2) return true;
  if (!(n & 1)) return false;
  n >>= 1;
  return (_bits[n / _sz] & (1 << (n % _sz))) == 0;
}
void sieve(int n = maxPrime) {
  memset(_bits, 0, sizeof(_bits));
  _bits[0] = 0;
  for (int i = 3; i * i <= n; i += 2)
    if (isPrime(i)) {
      for (int j = i * i; j <= n; j += 2 * i)
        _bits[(j >> 1) / _sz] |= (1 << ((j >> 1) % _sz));
    }
}
void getPrimes(vector<int> &pr, int n = maxPrime) {
  sieve(n);
  pr.clear();
  pr.push_back(2);
  for (int i = 3; i <= n; i += 2)
    if (isPrime(i)) pr.push_back(i);
}
vector<int> arr, ans;
int dp[105][1 << 17];
int num[60];
int solve(int n, int msk) {
  if (n < 0) return 0;
  int &ret = dp[n][msk];
  if (ret == -1) {
    ret = solve(n - 1, msk) + arr[n] - 1;
    for (int i = int(1); i < int(60); i++)
      if ((num[i] & msk) == 0) {
        ret = min(ret, solve(n - 1, msk | num[i]) + abs(arr[n] - i));
      }
  }
  return ret;
}
void back(int n, int msk) {
  if (n < 0) return;
  if (solve(n, msk) == solve(n - 1, msk) + arr[n] - 1) {
    ans[n] = 1;
    back(n - 1, msk);
    return;
  }
  for (int i = int(1); i < int(60); i++)
    if ((num[i] & msk) == 0) {
      if (solve(n, msk) == solve(n - 1, msk | num[i]) + abs(arr[n] - i)) {
        ans[n] = i;
        back(n - 1, msk | num[i]);
        return;
      }
    }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  getPrimes(prime);
  for (int i = int(1); i < int(60); i++) {
    num[i] = 0;
    for (int j = 0; j < int(int((prime).size())); j++)
      if (i % prime[j] == 0) num[i] |= 1 << j;
  }
  int n;
  cin >> n;
  ans = arr = vector<int>(n);
  for (int i = 0; i < int(n); i++) {
    cin >> arr[i];
  }
  memset(dp, -1, sizeof(dp));
  solve(n - 1, 0);
  back(n - 1, 0);
  int sum = 0;
  for (int i = 0; i < int(n); i++) {
    cout << ans[i] << " ";
    sum += abs(ans[i] - arr[i]);
  }
  return 0;
}
