#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 110;
const int SN = 1 << 16;
int n;
int a[MAXN];
int dp[MAXN][SN + 7];
int s[60];
pair<int, int> route[MAXN][SN + 7];
int prime[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
inline int getstate(int a) {
  int u = 0;
  for (int i = 0; i < 16; i++) {
    while (a % prime[i] == 0) {
      a /= prime[i];
      u |= (1 << i);
    }
  }
  return u;
}
int GetNumOfOne(int x) {
  int count = 0;
  while (x) {
    count++;
    x = x & (x - 1);
  }
  return count;
}
void print(int last, int id) {
  if (id == 1) {
    cout << route[id][last].second;
    return;
  }
  print(route[id][last].first, id - 1);
  cout << ' ' << route[id][last].second;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  for (int i = 1; i < 60; i++) s[i] = getstate(i);
  cin >> n;
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (int i = 1; i < n + 1; i++)
    for (int j = 0; j < SN; j++)
      if (GetNumOfOne(j) < i) {
        if (dp[i][j] > dp[i - 1][j] + a[i] - 1) {
          dp[i][j] = dp[i - 1][j] + a[i] - 1;
          route[i][j].first = j;
          route[i][j].second = 1;
        }
        for (int k = 0; k < 60; k++)
          if ((j & s[k]) == 0) {
            if (dp[i][j | s[k]] > dp[i - 1][j] + abs(k - a[i])) {
              dp[i][j | s[k]] = dp[i - 1][j] + abs(k - a[i]);
              route[i][j | s[k]].first = j;
              route[i][j | s[k]].second = k;
            }
          }
      }
  int ans = INF;
  int last;
  for (int j = 0; j < (1 << 16); j++)
    if (ans > dp[n][j]) {
      ans = dp[n][j];
      last = j;
    }
  print(last, n);
  cout << endl;
  return 0;
}
