#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAX = 110;
int cur = 0, vis[MAX], prime[MAX], state[MAX];
vector<int> C;
int dp[MAX][1 << 17], a[MAX], b[MAX], n, res[MAX][1 << 17];
void init() {
  for (int i = 2; i < MAX; i++) {
    if (!vis[i]) prime[cur++] = i;
    for (int j = i; j < MAX; j += i) vis[j] = 1;
  }
  memset(state, 0, sizeof(state));
  for (int i = 2; i < 70; i++) {
    for (int j = 0; j < 18; j++) {
      if (i % prime[j] == 0) state[i] |= (1 << j);
    }
  }
}
int dfs(int pos, int s) {
  if (pos > n) return 0;
  if (~dp[pos][s]) return dp[pos][s];
  int ans = inf;
  for (int i = 1; i < 60; i++) {
    if (s & state[i]) continue;
    int t = dfs(pos + 1, s | state[i]) + abs(i - a[pos]);
    if (ans > t) {
      ans = t;
      res[pos][s] = i;
    }
  }
  return dp[pos][s] = ans;
}
int main() {
  init();
  while (scanf("%d", &n) == 1) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    memset(dp, -1, sizeof(dp));
    dfs(1, 0);
    int s = 0;
    for (int i = 1; i <= n; i++) {
      C.push_back(res[i][s]);
      int k = res[i][s];
      s = s | (state[k]);
    }
    for (int i = 0; i < C.size(); i++) {
      printf("%d ", C[i]);
    }
    printf("\n");
  }
}
