#include <bits/stdc++.h>
using namespace std;
int N, A[128], M[128];
vector<int> P;
int dp[128][1 << 17];
bool isPrime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
void pre() {
  for (int i = 2; i <= 60; i++)
    if (isPrime(i)) P.push_back(i);
  memset(M, 0, sizeof(M));
  for (int i = 2; i <= 60; i++) {
    for (int j = 0; j < P.size(); j++)
      if ((i % P[j]) == 0) M[i] = M[i] + (1 << j);
  }
}
int f(int pos, int mask) {
  if (pos == N) return 0;
  if (dp[pos][mask] != -1) return dp[pos][mask];
  int ans = (1 << 29);
  for (int i = 1; i <= 2 * A[pos]; i++) {
    if ((mask & M[i]) == 0)
      ans = min(ans, abs(A[pos] - i) + f(pos + 1, mask | M[i]));
  }
  return dp[pos][mask] = ans;
}
vector<int> V;
void rec(int pos, int mask) {
  if (pos == N) return;
  for (int i = 1; i <= 2 * A[pos]; i++) {
    if ((mask & M[i]) != 0) continue;
    if (f(pos, mask) == abs(A[pos] - i) + f(pos + 1, mask | M[i])) {
      V.push_back(i);
      rec(pos + 1, mask | M[i]);
      return;
    }
  }
}
int main() {
  scanf("%d", &N);
  pre();
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  memset(dp, -1, sizeof(dp));
  rec(0, 0);
  for (int i = 0; i < V.size(); i++)
    printf("%d%s", V[i], (i == V.size() - 1) ? "\n" : " ");
}
