#include <bits/stdc++.h>
using namespace std;
vector<int> prime;
bool vis[65];
const int up = (1 << 17);
const int max_n = 105;
int a[max_n], s[max_n], dp[max_n][up + 5], path[max_n][up + 5];
void print(int x) {
  vector<int> res;
  while (x > 0) {
    res.push_back(x % 2);
    x >>= 1;
  }
  reverse(res.begin(), res.end());
  for (int i : res) printf("%d", i);
  puts("");
}
int main() {
  for (int i = 2; i <= 60; i++) {
    if (!vis[i]) prime.push_back(i);
    for (int j = 0; j < prime.size() && i * prime[j] <= 60; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int i = 1; i < 60; i++) {
    s[i] = 0;
    int now = i;
    for (int j = 0; j < prime.size(); j++) {
      while (now % prime[j] == 0) {
        s[i] |= (1 << j);
        now /= prime[j];
      }
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(path, -1, sizeof path);
  dp[0][0] = 0;
  path[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < up; j++)
      if (path[i - 1][j] != -1) {
        for (int k = 1; k < 60; k++) {
          if (j & s[k]) continue;
          int nxt = j | s[k];
          if (path[i][nxt] == -1 || dp[i][nxt] > dp[i - 1][j] + abs(k - a[i])) {
            dp[i][nxt] = dp[i - 1][j] + abs(k - a[i]);
            path[i][nxt] = k;
          }
        }
      }
  }
  int ans = 1e9, pos = -1;
  for (int i = 0; i < up; i++) {
    if (dp[n][i] < ans && path[n][i] != -1) {
      ans = dp[n][i];
      pos = i;
    }
  }
  vector<int> res;
  int now = n;
  while (now >= 1) {
    res.push_back(path[now][pos]);
    pos ^= s[path[now][pos]];
    now--;
  }
  reverse(res.begin(), res.end());
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  puts("");
  return 0;
}
