#include <bits/stdc++.h>
using namespace std;
const int _N = 1e5 + 5;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int n, arr[105], fac[66], vis[66], road[101][(1 << 18)], dp[101][(1 << 18)];
vector<int> primes;
void sieve() {
  for (int i = 2; i <= 60; i++) {
    if (vis[i]) continue;
    for (int j = i * i; j <= 60; j += i) {
      vis[j] = 1;
    }
    primes.push_back(i);
  }
}
void init() {
  for (int i = 1; i <= 60; i++) {
    int bit = 0;
    for (int j = 0; j < (int)primes.size(); j++) {
      if (i % primes[j] == 0) bit |= (1 << j);
    }
    fac[i] = bit;
  }
  memset(dp, -1, sizeof dp);
  memset(road, 0, sizeof road);
}
int solve(int idx, int bitmask) {
  if (idx == n) return 0;
  if (dp[idx][bitmask] != -1) return dp[idx][bitmask];
  int res = 1e5;
  for (int i = 1; i <= 60; i++) {
    if ((fac[i] & bitmask) == 0) {
      int var = abs(arr[idx] - i) + solve(idx + 1, bitmask | fac[i]);
      if (var < res) {
        res = var;
        road[idx][bitmask] = i;
      }
    }
  }
  return dp[idx][bitmask] = res;
}
void print(int idx, int bitmask) {
  if (idx == n) return;
  cout << road[idx][bitmask] << " ";
  print(idx + 1, fac[road[idx][bitmask]] | bitmask);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cout << fixed;
  cout << setprecision(15);
  sieve();
  init();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  solve(0, 0);
  print(0, 0);
  return 0;
}
