#include <bits/stdc++.h>
using namespace std;
int dp[105][1 << 18];
int taken[105][1 << 18];
int n;
vector<int> primes;
int mascara[65];
int getMask(int number) {
  if (number == 1) return 0;
  if (mascara[number]) return mascara[number];
  int mask = 0;
  for (int i = 0; i < primes.size(); i++) {
    if (number % primes[i] == 0) mask |= (1 << i);
  }
  return mascara[number] = mask;
}
int v[200];
int solve(int pos, int bitmask) {
  if (pos == n) return 0;
  if (dp[pos][bitmask] != -1) return dp[pos][bitmask];
  int ans = v[pos] - 1 + solve(pos + 1, bitmask);
  taken[pos][bitmask] = 1;
  for (int i = 2; i <= 55; i++) {
    int mask = getMask(i);
    int gcd = bitmask & mask;
    if (gcd) continue;
    int cur = abs(v[pos] - i) + solve(pos + 1, bitmask | mask);
    if (cur < ans) {
      taken[pos][bitmask] = i;
      ans = cur;
    }
  }
  return dp[pos][bitmask] = ans;
}
int main() {
  primes.push_back(2);
  primes.push_back(3);
  primes.push_back(5);
  primes.push_back(7);
  primes.push_back(11);
  primes.push_back(13);
  primes.push_back(17);
  primes.push_back(19);
  primes.push_back(23);
  primes.push_back(29);
  primes.push_back(31);
  primes.push_back(37);
  primes.push_back(41);
  primes.push_back(43);
  primes.push_back(47);
  primes.push_back(53);
  primes.push_back(59);
  primes.push_back(61);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  memset(dp, -1, sizeof dp);
  solve(0, 0);
  int mask = 0;
  for (int i = 0; i < n; i++) {
    int took = taken[i][mask];
    cout << took << " ";
    mask |= getMask(took);
  }
  return 0;
}
