#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool EQ2(double a, double b) { return fabs(a - b) < 1e-7; }
int n, seive[61], prime[61], store[60], c;
int a[110];
int dp[110][(1 << 17) + 10];
pair<int, int> nxt[110][(1 << 17) + 10];
int ans[110][(1 << 17) + 10];
void seiveGen() {
  int sqrtn = sqrt(61);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (!seive[i >> 1]) {
      for (int j = i * i; j < 61; j += i + i) {
        seive[j >> 1] = 1;
      }
    }
  }
  prime[c++] = 2;
  for (int i = 3; i < 61; i += 2) {
    if (!seive[i >> 1]) prime[c++] = i;
  };
  prime[c++] = 100000000;
}
void init() {
  for (int i = 1; i < 61; i++) {
    for (int j = 0; prime[j] <= i; ++j) {
      if (i % prime[j] == 0) {
        store[i] = setBit(store[i], j);
      }
    };
  }
}
int recur(int index, int mask) {
  if (index == n) return 0;
  int &ret = dp[index][mask];
  if (ret != -1) return ret;
  ret = 100000000;
  for (int i = 1; i < 61; ++i) {
    if (store[i] & mask) continue;
    int temp = recur(index + 1, mask | store[i]);
    if (temp + abs(i - a[index]) < ret) {
      nxt[index][mask] = pair<int, int>(index + 1, mask | store[i]);
      ret = temp + abs(i - a[index]);
      ans[index][mask] = i;
    }
  }
  return ret;
}
void ansGen() {
  recur(0, 0);
  pair<int, int> cur(0, 0);
  ;
  for (int i = 0; i < n; ++i) {
    cout << ans[cur.first][cur.second] << " ";
    cur = nxt[cur.first][cur.second];
  }
}
int main() {
  seiveGen();
  init();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  ansGen();
  return 0;
}
