#include <bits/stdc++.h>
using namespace std;
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
long long int arr[100005];
long long int dp[105][1 << 17][2];
long long int prim[] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                        29, 31, 37, 41, 43, 47, 53, 59};
void solve() {
  long long int n;
  cin >> n;
  memset(dp, 1000000009, sizeof(dp));
  ;
  for (int i = 0; i < n; i++) cin >> arr[i];
  ;
  for (long long int i = 0; i < 1 << 17; ++i) {
    dp[0][i][0] = 0;
    dp[0][i][1] = -1LL;
  }
  for (long long int i = 1; i < n + 1; ++i) {
    for (long long int j = 1; j < 61; ++j) {
      long long int x = 0LL;
      for (long long int k = 0; k < 17; ++k) {
        if (j % (prim[k]) == 0) x += (1 << k);
      }
      long long int fac = (~x) & ((1 << 17) - 1);
      for (long long int k = fac;; k = (k - 1) & fac) {
        if (dp[i - 1][k][0] + abs(arr[i - 1] - j) < dp[i][k | x][0]) {
          dp[i][k | x][0] = dp[i - 1][k][0] + abs(arr[i - 1] - j);
          dp[i][k | x][1] = j;
        }
        if (k == 0) break;
      }
    }
    long long int mn = inf, pos = 0LL, t;
  }
  long long int mn = inf, pos = 0LL, t;
  for (long long int i = 0; i < 1 << 17; ++i) {
    if (mn > dp[n][i][0]) {
      mn = dp[n][i][0];
      pos = i;
      t = dp[n][i][1];
      ;
    }
  }
  vector<long long int> ans;
  long long int curr = n;
  while (curr != 0) {
    ans.push_back(dp[curr][pos][1]);
    long long int x = 0LL;
    for (long long int i = 0; i < 17; ++i) {
      if (dp[curr][pos][1] % (prim[i]) == 0) x += (1 << i);
    }
    pos = (~x) & pos;
    curr--;
  }
  reverse((ans).begin(), (ans).end());
  for (long long int it : ans) cout << it << " ";
  cout << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int tc = 1;
  while (tc--) {
    solve();
  }
}
