#include <bits/stdc++.h>
using namespace std;
const int inf = (long long)1e9;
const int mod = inf + 7;
const double pi = acos(-1.0);
int n;
int a[111];
vector<int> v;
int dp[111][(1 << 17) + 123], premask[60], p[111][(1 << 17) + 123];
bool prime(int x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= 60; ++i) {
    if (prime(i)) v.push_back(i);
  }
  for (int i = 1; i <= 60; ++i) {
    for (int j = 0; j < (int)v.size(); ++j) {
      if (i % v[j] == 0) premask[i] ^= (1 << j);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int mask = 0; mask < (1 << 17); ++mask) dp[i][mask] = inf;
  for (int i = 0; i < n; ++i) {
    for (int mask = 0; mask < (1 << 17); ++mask) {
      for (int x = 1; x <= 2 * a[i + 1]; ++x) {
        if ((mask & premask[x])) continue;
        int nmask = mask ^ premask[x];
        if (dp[i + 1][nmask] > dp[i][mask] + abs(a[i + 1] - x)) {
          dp[i + 1][nmask] = dp[i][mask] + abs(a[i + 1] - x);
          p[i + 1][nmask] = x;
        }
      }
    }
  }
  int q = 0, mn = inf;
  for (int mask = 0; mask < (1 << 17); ++mask) {
    if (dp[n][mask] < mn) {
      mn = dp[n][mask];
      q = mask;
    }
  }
  vector<int> ans;
  for (int i = n; i >= 1; --i) {
    int number = p[i][q];
    ans.push_back(number);
    q = q ^ premask[number];
  }
  reverse((ans).begin(), (ans).end());
  for (int i = 0; i < (int)ans.size(); ++i) cout << ans[i] << " ";
  return 0;
}
