#include <bits/stdc++.h>
using namespace std;
int dirx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int diry[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int N = 1e2 + 5, M = (1 << 17) + 5, inf = 1e7;
int a[N], dp[N][M], bit[N], n;
bool ip(int i) {
  for (int it = 2; it * it <= i; it++) {
    if (i % it == 0) return false;
  }
  return true;
}
int rec(int idx, int mask) {
  int &res = dp[idx][mask];
  if (idx == n) return res = 0;
  if (~res) return res;
  res = inf;
  for (long long i = (1); i <= (60); ++i) {
    if (bit[i] & mask) continue;
    res = min(res, rec(idx + 1, mask | bit[i]) + abs(a[idx] - (int)i));
  }
  return res;
}
void print(int idx, int mask) {
  if (idx == n) return;
  for (long long i = (1); i <= (60); ++i) {
    if ((bit[i] & mask) == 0 &&
        dp[idx][mask] == (dp[idx + 1][mask | bit[i]] + abs(a[idx] - i))) {
      cout << i << " ";
      print(idx + 1, mask | bit[i]);
      break;
    }
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  int idx = 0;
  for (long long i = (2); i <= (60); ++i) {
    if (ip(i)) {
      for (int j = i; j <= 60; j += i) {
        bit[j] |= (1 << idx);
      }
      idx++;
    }
  }
  rec(0, 0);
  print(0, 0);
}
