#include <bits/stdc++.h>
using namespace std;
std::vector<int> numbers;
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int mask[60];
int best[101][(1 << 16)];
int last[101][(1 << 16)];
int main(int argc, const char* argv[]) {
  int N;
  cin >> N;
  numbers.resize(N);
  for (int k = 2; k < 60; k++)
    for (int i = 0; i < 16; i++)
      if (k % primes[i] == 0) mask[k] |= (1 << i);
  for (int i = 0; i < N; i++) cin >> numbers[i];
  memset(best, 0x7f, sizeof(best));
  memset(&best[0][0], 0, (1 << 16) * sizeof(best[0][0]));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (1 << 16); j++)
      for (int k = 1; k < 60; k++) {
        if (j & mask[k]) continue;
        int cur_best = best[i + 1][j | mask[k]];
        int cur = best[i][j] + abs(numbers[i] - k);
        if (cur < cur_best) {
          best[i + 1][j | mask[k]] = cur;
          last[i + 1][j | mask[k]] = k;
        }
      }
  }
  std::vector<int> ans(N);
  int best_mask = 0;
  for (int j = 1; j < (1 << 16); j++)
    if (best[N][j] < best[N][best_mask]) best_mask = j;
  for (int i = N; i > 0; i--) {
    ans[i - 1] = last[i][best_mask];
    best_mask &= ~mask[ans[i - 1]];
  }
  for (typeof(ans.end()) it = ans.begin(); it != ans.end(); ++it)
    cout << *it << ' ';
  cout << endl;
  return 0;
}
