#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
vector<int> primes;
int dp[101][1 << 18];
int getx[65];
int _getx(int b) {
  int x = 0;
  for (int j = 0; j < 32; j++) {
    if (b % primes[j] == 0) x |= 1 << j;
  }
  return x;
}
int go(int i, int j) {
  if (i == n) return 0;
  int &ret = dp[i][j];
  if (ret != -1)
    return ret;
  else
    ret = 1 << 30;
  for (int k = 1; k <= 60; k++) {
    int x = getx[k];
    if (x & j) continue;
    ret = min(ret, go(i + 1, j | x) + abs(a[i] - k));
  }
  return ret;
}
int bt(int i, int j) {
  if (i == n) return 0;
  int &ret = dp[i][j];
  for (int k = 1; k <= 60; k++) {
    int x = getx[k];
    if (x & j) continue;
    if (ret == go(i + 1, j | x) + abs(a[i] - k)) {
      cout << k;
      if (i == n - 1)
        cout << endl;
      else
        cout << " ";
      bt(i + 1, j | x);
      return 0;
    }
  }
  return ret;
}
int main() {
  for (int i = 2; i < 500; i++) {
    bool isprime = true;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) isprime = false;
    }
    if (isprime) primes.push_back(i);
  }
  for (int i = 0; i < 65; i++) getx[i] = _getx(i);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a.push_back(ai);
  }
  go(0, 0);
  bt(0, 0);
}
