#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x70707070;
const long long MAXLONG = (long long)1 << 60;
const int MAXN = 101;
const int MAXV = 61;
int dp[MAXN][1 << 17], pre[MAXN][1 << 17], corr[MAXN][1 << 17];
int bm[MAXV];
int arr[MAXN];
vector<int> primes;
int n;
void find_prime() {
  for (long long i = (2); i < (MAXV); i += 1) {
    bool ok = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      primes.push_back(i);
    }
  }
}
void find_factor() {
  for (long long i = (1); i < (MAXV); i += 1) {
    int bit = 0;
    for (long long j = (0); j < (primes.size()); j += 1) {
      int p = primes[j];
      if (i % p == 0) {
        bit |= 1 << j;
      }
    }
    bm[i] = bit;
  }
}
int main() {
  find_prime();
  find_factor();
  while (cin >> n) {
    for (long long i = (1); i < (n + 1); i += 1) {
      scanf("%d", &arr[i]);
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    int all = 1 << primes.size();
    for (long long i = (0); i < (n); i += 1) {
      for (long long j = (0); j < (all); j += 1) {
        if (dp[i][j] == -1) continue;
        for (long long k = (1); k < (MAXV); k += 1) {
          int bit = bm[k];
          if (bit & j) continue;
          if (dp[i + 1][j | bit] == -1 ||
              dp[i + 1][j | bit] > dp[i][j] + abs(arr[i + 1] - k)) {
            dp[i + 1][j | bit] = dp[i][j] + abs(arr[i + 1] - k);
            corr[i + 1][j | bit] = k;
            pre[i + 1][j | bit] = j;
          }
        }
      }
    }
    int small = -1;
    int from = -1;
    for (long long i = (0); i < (all); i += 1) {
      if (dp[n][i] == -1) continue;
      if (small == -1 || dp[n][i] < small) {
        small = dp[n][i];
        from = i;
      }
    }
    int res[MAXN];
    for (long long i = (n); i > (0); i -= 1) {
      res[i] = corr[i][from];
      from = pre[i][from];
    }
    for (long long i = (1); i < (n + 1); i += 1) {
      printf("%d ", res[i]);
    }
    puts("");
  }
  return 0;
}
