#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > matmul(vector<vector<long long> > &a,
                                  vector<vector<long long> > &b) {
  int i, j, k, n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      long long temp = 0;
      for (k = 0; k < n; k++)
        temp = (temp + a[i][k] * b[k][j]) % (1000000007LL);
      ans[i][j] = temp;
    }
  return ans;
}
vector<vector<long long> > matpwr(vector<vector<long long> > &a, long long p) {
  int n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (int i = 0; i < n; i++) ans[i][i] = 1;
  while (p) {
    if (p & 1) ans = matmul(ans, a);
    a = matmul(a, a);
    p >>= 1;
  }
  return ans;
}
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long invMod(long long n, long long mod = (1000000007LL)) {
  return pwr(n, mod - 2);
}
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int n, arr[105], maskVal[60], DP[105][1 << 17], ele[105][1 << 17],
    go[105][1 << 17], p = 16;
vector<int> valid[(1 << 17) + 2];
int dp(int pos, int mask) {
  if (pos == n) return 0;
  if (DP[pos][mask] != -1) return DP[pos][mask];
  int ans = (100000005);
  for (int i = 0; i < (int)valid[mask].size(); i++) {
    int val = valid[mask][i];
    if (abs(val - arr[pos]) + dp(pos + 1, maskVal[val] | mask) < ans) {
      ans = abs(val - arr[pos]) + dp(pos + 1, maskVal[val] | mask);
      ele[pos][mask] = val;
      go[pos][mask] = maskVal[val] | mask;
    }
  }
  return DP[pos][mask] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int mask = 0; mask < (1 << p); mask++)
    for (int i = 1; i <= 58; i++) {
      bool invalid = false;
      for (int j = 0; j < p; j++)
        if (i % primes[j] == 0 && ((mask >> j) & 1)) invalid = true;
      if (!invalid) valid[mask].push_back(i);
    }
  for (int i = 1; i <= 58; i++) {
    int mask = 0;
    for (int j = 0; j < p; j++)
      if (i % primes[j] == 0) mask |= (1 << j);
    maskVal[i] = mask;
  }
  memset(DP, -1, sizeof(DP));
  memset(ele, -1, sizeof(ele));
  memset(go, -1, sizeof(go));
  dp(0, 0);
  int i = 0, mask = 0;
  while (i < n) {
    assert(ele[i][mask] != -1);
    assert(go[i][mask] != -1);
    cout << ele[i][mask] << " ";
    mask = go[i][mask];
    i++;
  }
  return 0;
}
