#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? b_pow(x * x, n / 2) * (n % 2 ? x : 1) : 1ll;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
int dp[110][1 << 18];
int a[110];
int n;
vector<int> o;
int flag[62];
int dfs(int x, int bit) {
  if (x >= n) return 0;
  if (dp[x][bit] != -1) return dp[x][bit];
  int res = 1e9;
  for (int i = 1; i <= 60; i++) {
    if (i == 1) {
      res = min(res, dfs(x + 1, bit) + abs(a[x] - i));
    } else if (!(flag[i] & bit)) {
      res = min(res, dfs(x + 1, bit | flag[i]) + abs(a[x] - i));
    }
  }
  return dp[x][bit] = res;
}
int rec(int x, int bit) {
  if (x >= n) return 0;
  int res = 1e9;
  for (int i = 1; i <= 60; i++) {
    if (i == 1) {
      if (dfs(x, bit) == dfs(x + 1, bit) + abs(a[x] - i)) {
        cout << i << " ";
        rec(x + 1, bit);
        return 0;
      }
    } else if (!(flag[i] & bit)) {
      if (dfs(x, bit) == dfs(x + 1, bit | flag[i]) + abs(a[x] - i)) {
        cout << i << " ";
        rec(x + 1, bit | flag[i]);
        return 0;
      }
    }
  }
  return dp[x][bit] = res;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= 60; i++) {
    if (isprime(i)) {
      o.push_back(i);
    }
  }
  for (int i = 1; i <= 60; i++) {
    for (int j = 0; j < o.size(); j++)
      if (i % o[j] == 0) {
        flag[i] |= (1 << j);
      }
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  rec(0, 0);
  cout << endl;
}
