#include <bits/stdc++.h>
using namespace std;
int dp[1 << 16][100];
int b[1 << 16][100];
vector<int> bucket[16];
int bucketMask[58 + 1];
int a[100];
void setBucket() {
  bool sieve[58 + 1];
  memset(sieve, true, sizeof sieve);
  int ctr = 0;
  for (int p = 2; p <= 58; p++)
    if (sieve[p]) {
      for (int k = 1; k * p <= 58; k++) {
        sieve[k * p] = false;
        bucket[ctr].push_back(k * p);
      }
      ctr++;
    }
  memset(bucketMask, 0, sizeof bucketMask);
  for (int i = 0; i < 16; i++)
    for (int j = 0; j < bucket[i].size(); j++)
      bucketMask[bucket[i][j]] = bucketMask[bucket[i][j]] | (1 << i);
}
int n;
int OPT(int mask, int i) {
  if (i == n) return 0;
  if (dp[mask][i] != -1) return dp[mask][i];
  int best = OPT(mask, i + 1) + abs(a[i] - 1);
  b[mask][i] = 1;
  for (int k = 2; k <= 58; k++)
    if ((mask & bucketMask[k]) == 0) {
      int ans = OPT(mask | bucketMask[k], i + 1) + abs(a[i] - k);
      if (ans < best) {
        best = ans;
        b[mask][i] = k;
      }
    }
  return dp[mask][i] = best;
}
int main() {
  setBucket();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(dp, -1, sizeof dp);
  OPT(0, 0);
  int B = 0;
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << b[B][i];
    B = B | bucketMask[b[B][i]];
  }
  return 0;
}
