#include <bits/stdc++.h>
using namespace std;
pair<int, int> add_pair(pair<int, int> a, pair<int, int> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
int power(int a, int b) {
  int res = 1;
  a = a % 998244353;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 998244353;
      b--;
    }
    a = (a * a) % 998244353;
    b >>= 1;
  }
  return res;
}
int fermat_inv(int y) { return power(y, 998244353 - 2); }
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int arr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int F[60];
const int N = 1 << 17;
void pre() {
  int i, j, mask;
  for (i = (1); i < (60); i += (1)) {
    mask = 0;
    for (j = (0); j < (17); j += (1)) {
      if (i % arr[j] == 0) {
        mask = mask | (1 << j);
      }
    }
    F[i] = mask;
  }
}
void solve() {
  int n, i, mask, submask, j, mn, val;
  cin >> n;
  int a[n];
  for (i = (0); i < (n); i += (1)) cin >> a[i];
  int dp[n][N];
  int ans[n][N];
  for (i = (0); i < (n); i += (1))
    for (j = (0); j < (N); j += (1)) dp[i][j] = (int)1e9;
  for (i = (1); i < (60); i += (1)) {
    if (dp[0][F[i]] > (int)abs(a[0] - i)) {
      dp[0][F[i]] = (int)abs(a[0] - i);
      ans[0][F[i]] = i;
    }
  }
  for (i = (1); i < (n); i += (1)) {
    for (j = (1); j < (60); j += (1)) {
      for (submask = (0); submask < (N); submask += (1)) {
        if (submask & F[j]) continue;
        if (dp[i][submask | F[j]] > dp[i - 1][submask] + (int)abs(a[i] - j)) {
          dp[i][submask | F[j]] = dp[i - 1][submask] + (int)abs(a[i] - j);
          ans[i][submask | F[j]] = j;
        }
      }
    }
  }
  mn = (int)1e9;
  for (i = (0); i < (N); i += (1)) {
    if (dp[n - 1][i] < mn) {
      mn = dp[n - 1][i];
      val = i;
    }
  }
  int b[n];
  b[n - 1] = ans[n - 1][val];
  for (i = (n - 2); i > (-1); i -= (1)) {
    val = val ^ F[b[i + 1]];
    b[i] = ans[i][val];
  }
  for (i = (0); i < (n); i += (1)) cout << b[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  pre();
  while (t--) {
    solve();
  }
  return 0;
}
