#include <bits/stdc++.h>
using namespace std;
vector<int> primes, ad[70];
bool status[105];
int n, ara[105], dp[105][(1 << 18) + 5], mp[105], dir[105][(1 << 18) + 5];
bool Check(int n, int pos) { return (bool)(n & (1 << pos)); }
int Set(int n, int pos) { return n = (n | (1 << pos)); }
void gen() {
  int i, j, si = sqrt(102);
  for (i = 3; i <= si; i += 2) {
    if (!status[i]) {
      for (j = i * i; j <= 100; j += i) {
        status[j] = true;
      }
    }
  }
  primes.push_back(2);
  for (i = 3; i <= 100; i += 2) {
    if (!status[i]) {
      primes.push_back(i);
    }
  }
  memset(mp, -1, sizeof mp);
  for (i = 0; i < primes.size(); i++) {
    mp[primes[i]] = i;
  }
}
int func(int indx, int mask) {
  if (indx == n) {
    return 0;
  }
  if (dp[indx][mask] != -1) {
    return dp[indx][mask];
  }
  int ans = ara[indx] - 1 + func(indx + 1, mask);
  dir[indx][mask] = 1;
  for (int val = 2; val <= 60; val++) {
    bool flag = true;
    for (int v : ad[val]) {
      bool p = Check(mask, mp[v]);
      if (p) {
        flag = false;
        break;
      }
    }
    if (flag) {
      int temp = mask;
      for (int v : ad[val]) {
        temp = Set(temp, mp[v]);
      }
      int ret = abs(ara[indx] - val) + func(indx + 1, temp);
      if (ret < ans) {
        ans = ret;
        dir[indx][mask] = val;
      }
    }
  }
  return dp[indx][mask] = ans;
}
void go(int indx, int mask) {
  if (indx == n) return;
  cout << dir[indx][mask] << ' ';
  int temp = mask;
  if (dir[indx][mask] == 1) {
    go(indx + 1, mask);
  } else {
    for (int v : ad[dir[indx][mask]]) {
      temp = Set(temp, mp[v]);
    }
    go(indx + 1, temp);
  }
}
int main() {
  gen();
  int i, j;
  for (i = 2; i <= 60; i++) {
    int num = i;
    for (int v : primes) {
      if (num % v == 0) {
        ad[i].push_back(v);
      }
    }
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ara[i];
  }
  memset(dp, -1, sizeof dp);
  int ans = func(0, 0);
  go(0, 0);
  cout << endl;
  return 0;
}
