#include <bits/stdc++.h>
using namespace std;
const vector<int> PRIMES{2,  3,  5,  7,  11, 13, 17, 19, 23,
                         29, 31, 37, 41, 43, 47, 53, 59};
const pair<int, int> NA{-1, -1};
const int INF = INT_MAX / 2;
int n;
vector<int> a;
vector<vector<pair<int, int>>> cache;
int total = 0, total_hit = 0;
vector<vector<int>> prime_factors;
pair<int, int> dfs(int which, int prime_used) {
  if (which >= n) {
    return {0, -1};
  }
  total++;
  if (cache[which][prime_used] != NA) {
    total_hit++;
    return cache[which][prime_used];
  }
  pair<int, int> ans{INF, -1};
  int ub = a[which] + a[which] - 1;
  for (int b = 1; b < ub + 1; b++) {
    int new_prime_used = prime_used;
    bool good = true;
    for (auto i : prime_factors[b]) {
      if (((1 << i) & prime_used) > 0) {
        good = false;
        break;
      }
      new_prime_used += 1 << i;
    }
    if (!good) {
      continue;
    }
    int diff = abs(a[which] - b);
    auto ans1 = dfs(which + 1, new_prime_used);
    if (diff + ans1.first < ans.first) {
      ans.first = ans1.first + diff;
      ans.second = b;
    }
  }
  return cache[which][prime_used] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  {
    prime_factors = vector<vector<int>>(60);
    for (int i = 1; i < 60; i++) {
      for (int j = 0; j < PRIMES.size(); j++) {
        if (i < PRIMES[j]) {
          break;
        }
        if (i % PRIMES[j] == 0) {
          prime_factors[i].push_back(j);
        }
      }
    }
  }
  cache = vector<vector<pair<int, int>>>(
      n, vector<pair<int, int>>(1 << PRIMES.size(), NA));
  auto ans = dfs(0, 0);
  ;
  ;
  int which = 0, prime_used = 0;
  while (which < n) {
    int b = cache[which][prime_used].second;
    cout << b << ' ';
    if (b > 1) {
      for (int i = 0; i < PRIMES.size(); i++) {
        if (b % PRIMES[i] == 0) {
          prime_used += 1 << i;
        }
      }
    }
    which++;
  }
}
