#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 20, lg = (1 << (17)), maxm = 60 + 1, inf = 1e8;
vector<int> primes, a;
int b[maxn][lg], dp[maxn][lg];
int factors[maxn], mark[maxm];
int n;
void calcp() {
  mark[1] = 1;
  for (int i = 2; i < maxm; i++) {
    if (mark[i]) continue;
    primes.push_back(i);
    for (int c = 2 * i; c < maxm; c += i) mark[c] = 1;
  }
}
void primefact() {
  for (int i = 1; i < maxm; i++) {
    for (int j = 0; j < primes.size(); j++) {
      if (i % primes[j] == 0) {
        factors[i] |= (1 << j);
      }
    }
  }
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
}
int xor_delta(int a, int b) {
  int c = a - (a & b);
  return c;
}
int diffr(int a, int b) { return max(a - b, b - a); }
void calc() {
  for (int i = 0; i < n; i++) {
    for (int k = 1; k <= 60; k++) {
      int x = (~factors[k]) & ((1 << 17) - 1);
      for (int s = x;; s = (s - 1) & x) {
        if (i == 0 or dp[i - 1][s] + diffr(a[i], k) < dp[i][s | factors[k]]) {
          if (i) {
            dp[i][s | factors[k]] = dp[i - 1][s] + (diffr(a[i], k));
            b[i][factors[k] | s] = k;
          } else if (dp[i][s | factors[k]] > diffr(a[i], k)) {
            dp[i][s | factors[k]] = diffr(a[i], k);
            b[i][factors[k] | s] = k;
          }
        }
        if (!s) break;
      }
    }
  }
}
void answer() {
  int nmask = 0;
  int cmin = inf;
  for (int mask = 0; mask < (1 << 17); mask++)
    if (dp[n - 1][mask] < dp[n - 1][nmask]) nmask = mask;
  stack<int> ans;
  for (int i = n - 1; i > -1; i--) {
    ans.push(b[i][nmask]);
    nmask = nmask - factors[b[i][nmask]];
  }
  while (ans.size()) {
    cout << ans.top() << ' ';
    ans.pop();
  }
}
void print_binary(int a) {
  while (a) {
    cout << a % 2;
    a /= 2;
  }
}
void preset() {
  for (int i = 0; i < n; i++) fill(dp[i], dp[i] + lg, inf);
}
void test() {
  cout << diffr(7, 7);
  return;
  for (int i = 0; i < 60; i++) {
    cout << endl << i << ": ";
    print_binary(factors[i]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  calcp();
  primefact();
  input();
  preset();
  calc();
  answer();
}
