#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e15;
const long long int mod = 1000000007;
const int infInt = 1e9;
const double PI = acos(-1.00);
const double eps = 1e-6;
int a[110], n;
long long int divs[110];
int crib[110];
int dp[(1 << 16)][101];
bool vis[(1 << 16)][101];
vector<int> primes;
int f(int mask, int ind) {
  if (ind == 0) return 0;
  int ans = infInt;
  if (vis[mask][ind]) return dp[mask][ind];
  vis[mask][ind] = true;
  for (int i = 1; i < min(2 * a[ind], 54); i++) {
    if ((mask & divs[i]) == 0) {
      ans = min(ans, f(mask | divs[i], ind - 1) + abs(i - a[ind]));
    }
  }
  return dp[mask][ind] = ans;
}
void rec(int mask, int ind) {
  if (ind == 0) return;
  for (int i = 1; i < min(2 * a[ind], 54); i++) {
    if ((mask & divs[i]) == 0 and
        dp[mask][ind] == f(mask | divs[i], ind - 1) + abs(i - a[ind])) {
      rec(mask | divs[i], ind - 1);
      cout << i << " ";
      break;
    }
  }
}
void criba() {
  for (int i = 4; i <= 53; i += 2) crib[i] = 2;
  for (int i = 3; i * i <= 53; i += 2) {
    for (int j = i * i; j <= 53; j += 2 * i) {
      crib[j] = i;
    }
  }
  for (int i = 2; i <= 53; i++) {
    if (!crib[i]) primes.push_back(i);
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  criba();
  int tam = primes.size();
  for (int i = 2; i <= 53; i++) {
    for (int j = 0; j < tam; j++) {
      if (i % primes[j] == 0) divs[i] |= (1 << j);
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  f(0, n);
  rec(0, n);
}
