#include <bits/stdc++.h>
using namespace std;
int a[100], n, b[100], best = 3000, ones[101], ok[60][60];
void recurse(int *res, int *S, int len, int level) {
  int *S2 = S + len, sum = ones[n - level];
  for (int i = 0; i < level; ++i) sum += abs(a[n - level + i] - res[i]);
  if (sum < best) {
    for (int i = 0; i < n - level; ++i) b[i] = 1;
    for (int i = 0; i < level; ++i) b[n - level + i] = res[i];
    best = sum;
  }
  if (level < n)
    for (int i = 0; i < len; ++i) {
      int num = 0;
      for (int j = i + 1; j < len; ++j)
        if (ok[S[i]][S[j]]) S2[num++] = S[j];
      res[level] = S[i];
      recurse(res, S2, num, level + 1);
    }
}
int main() {
  int a2[100], res[20], S[1000], len = 0, factor[60];
  map<int, vector<int>> ans;
  for (int i = 1; i < 60; ++i) {
    for (int j = 1; j < 60; ++j) {
      ok[i][j] = (i == j) ? 0 : 1;
      for (int k = 2; k < 29; ++k)
        if (i % k == 0 && j % k == 0) {
          ok[i][j] = 0;
          break;
        }
    }
  }
  for (int i = 1; i < 60; ++i) factor[i] = 0;
  for (int i = 2; i < 60; ++i)
    for (int j = 2; i * j < 60; j++) factor[i * j] = i;
  for (int i = 2; i < 60; ++i)
    if (i <= 30 || i - 30 < abs(30 - factor[i])) S[len++] = i;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], a2[i] = a[i];
  sort(a, a + n);
  ones[0] = 0;
  for (int i = 1; i <= n; ++i) ones[i] = ones[i - 1] + a[i - 1] - 1;
  recurse(res, S, len, 0);
  for (int i = 0; i < n; ++i) ans[a[i]].push_back(b[i]);
  for (int i = 0; i < n; ++i) {
    cout << ans[a2[i]].back() << " ";
    ans[a2[i]].pop_back();
  }
  return 0;
}
