#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int N = 1e5 + 1;
const long long mod = 1e9 + 9;
const int bits = 19;
void solve() {
  vector<int> ok(61, 0);
  vector<int> mask(61);
  int ptr = 0;
  for (int i = 2; i <= 60; i++) {
    if (!ok[i]) {
      mask[i] |= (1 << ptr);
      for (int j = 2 * i; j <= 60; j += i) {
        ok[j] = 1;
        mask[j] |= (1 << ptr);
      }
      ptr++;
    }
  }
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<vector<int>> dp(n, vector<int>(1 << ptr + 1, inf)), store;
  store = dp;
  for (int i = 1; i <= 60; i++) {
    if (abs(arr[0] - i) < dp[0][mask[i]]) {
      dp[0][mask[i]] = abs(arr[0] - i);
      store[0][mask[i]] = i;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= (1 << ptr); j++) {
      int val = inf, ele = -1;
      for (int k = 1; k <= 60; k++) {
        if ((j & mask[k]) != mask[k]) continue;
        int omask = j ^ mask[k];
        int nval = min(dp[i - 1][omask] + abs(arr[i] - k), inf);
        if (nval < val) {
          val = nval;
          ele = k;
        }
      }
      dp[i][j] = min(val, inf);
      store[i][j] = ele;
    }
  }
  int smask = -1, val = inf;
  for (int i = 0; i <= (1 << ptr); i++) {
    if (dp[n - 1][i] < val) {
      smask = i;
      val = dp[n - 1][i];
    }
  }
  vector<int> ans;
  while (n--) {
    int ele = store[n][smask];
    smask ^= mask[ele];
    ans.push_back(ele);
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) {
    cout << x << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  std::cout << std::fixed << std::setprecision(20);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
