#include <bits/stdc++.h>
using namespace std;
int n;
int a[101];
int dp[101][1 << 17];
int M[61];
vector<int> prime;
bool isprime(int num) {
  int i;
  for (i = 2; i < num; ++i) {
    if (num % i == 0) return 0;
  }
  return 1;
}
void pre() {
  int i, j;
  for (i = 2; i < 60; ++i) {
    if (isprime(i)) prime.push_back(i);
  }
  memset(M, 0, sizeof(M));
  for (i = 2; i <= 60; ++i) {
    for (j = 0; j < prime.size(); ++j) {
      if (i % prime[j] == 0) M[i] = M[i] + (1 << j);
    }
  }
}
vector<int> ans;
int f(int pos, int mask) {
  int i;
  if (pos == n)
    return 0;
  else if (dp[pos][mask] != -1)
    return dp[pos][mask];
  else {
    int tmp = INT_MAX;
    for (i = 1; i <= 2 * a[pos]; ++i) {
      if ((mask & M[i]) == 0)
        tmp = min(tmp, abs(a[pos] - i) + f(pos + 1, mask | M[i]));
    }
    return dp[pos][mask] = tmp;
  }
}
void rec(int pos, int mask) {
  int i;
  if (pos == n)
    return;
  else {
    for (i = 1; i <= 2 * a[pos]; ++i) {
      if ((mask & M[i]) != 0) continue;
      if (f(pos, mask) == (abs(a[pos] - i) + f(pos + 1, mask | M[i]))) {
        ans.push_back(i);
        rec(pos + 1, mask | M[i]);
        return;
      }
    }
  }
}
int main() {
  int i;
  pre();
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  rec(0, 0);
  for (i = 0; i < n; ++i) cout << ans[i] << " ";
  return 0;
}
