#include <bits/stdc++.h>
using namespace std;
const int N = 17;
int dp[101][1 << N];
int prost[60], msk[60];
signed main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, c = 0;
  vector<int> pressf{0};
  cin >> n;
  for (int i = 1; i < 60; i++) {
    bool t = 1;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) t = 0;
    }
    if (t && i != 1) prost[i] = c++;
  }
  for (int i = 1; i < 60; i++) {
    int i1 = i;
    for (int j = 2; j * j <= i; j++) {
      while (i % j == 0) msk[i1] |= (1 << prost[j]), i /= j;
    }
    if (i > 1) msk[i1] |= (1 << prost[i]);
    i = i1;
  }
  for (int i = 0; i <= n; i++) {
    for (int mask = 0; mask < (1 << 17); mask++) dp[i][mask] = 1e9;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    pressf.push_back(a);
    for (int j = 1; j < 60; j++) {
      int r = abs(a - j);
      int f = msk[j];
      int x = (~msk[j]) & ((1 << 17) - 1);
      for (int s = x;; s = (s - 1) & x) {
        if (dp[i][s | f] > dp[i - 1][s] + r) dp[i][s | f] = dp[i - 1][s] + r;
        if (!s) break;
      }
    }
  }
  pair<int, int> minans = {1e9, 1e9};
  for (int i = 0; i < (1 << 17); i++) minans = min(minans, {dp[n][i], i});
  int v = minans.second;
  vector<int> kek;
  for (int i = n; i > 0; i--) {
    for (int j = 1; j < 60; j++) {
      if ((v ^ msk[j]) == v - msk[j] &&
          dp[i][v] == dp[i - 1][v ^ msk[j]] + abs(pressf[i] - j)) {
        v ^= msk[j];
        kek.push_back(j);
        break;
      }
    }
  }
  reverse(kek.begin(), kek.end());
  for (auto i : kek) cout << i << " ";
}
