#include <bits/stdc++.h>
using namespace std;
const int MAX_ELEMENT = 61;
const int MAXN = 101;
const int INF = 1E9;
const int NUMBER_OF_PRIMES = 16;
const int NUMBER_OF_MASK = (1 << NUMBER_OF_PRIMES) + 1;
const int primes[NUMBER_OF_PRIMES] = {2,  3,  5,  7,  11, 13, 17, 19,
                                      23, 29, 31, 37, 41, 43, 47, 53};
int mask_numbers[61];
int best_price[MAXN][NUMBER_OF_MASK];
int last_element[MAXN][NUMBER_OF_MASK];
int main() {
  int i, j, k;
  int val, mask;
  int N;
  cin >> N;
  vector<int> a(N);
  for (i = 0; i < N; i++) cin >> a[i];
  for (i = 1; i < MAX_ELEMENT; i++) {
    mask_numbers[i] = 0;
    for (j = 0; j < NUMBER_OF_PRIMES; j++)
      if (i % primes[j] == 0) mask_numbers[i] |= (1 << j);
  }
  best_price[0][0] = 0;
  for (mask = 1; mask < NUMBER_OF_MASK; mask++) best_price[0][mask] = INF;
  for (i = 1; i <= N; i++) {
    for (mask = 0; mask < NUMBER_OF_MASK; mask++) best_price[i][mask] = INF;
    for (val = 1; val < MAX_ELEMENT; val++) {
      for (mask = 0; mask < NUMBER_OF_MASK; mask++) {
        if ((mask & mask_numbers[val]) == mask_numbers[val] &&
            best_price[i][mask] > best_price[i - 1][mask ^ mask_numbers[val]] +
                                      abs(val - a[i - 1])) {
          best_price[i][mask] =
              best_price[i - 1][mask ^ mask_numbers[val]] + abs(val - a[i - 1]);
          last_element[i][mask] = val;
        }
      }
    }
  }
  int best_mask = 0;
  for (mask = 0; mask < NUMBER_OF_MASK; mask++)
    if (best_price[N][mask] < best_price[N][best_mask]) best_mask = mask;
  vector<int> ans(N);
  for (i = N; i > 0; i--) {
    ans[i - 1] = last_element[i][best_mask];
    best_mask ^= mask_numbers[ans[i - 1]];
  }
  for (i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
}
