#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
bool seive[1010000];
vector<int> prime;
void seiveGen(int limit) {
  limit += 100;
  int sqrtn = sqrt(limit);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (!seive[i >> 1]) {
      for (int j = i * i; j < limit; j += i + i) {
        seive[j >> 1] = 1;
      }
    }
  }
  prime.push_back(2);
  for (int i = 3; i < limit; i += 2) {
    if (!seive[i >> 1]) prime.push_back(i);
  }
}
const int mx = 131073;
int dp[123][mx];
int n, a[123], Mask[100];
bool dir[102][131073];
vector<int> fact[100];
void factor() {
  for (int i = 1; i <= 60; i++) {
    int mask = 0;
    for (int j = 0; j < 17; j++) {
      if (i % prime[j] == 0) {
        mask = setBit(mask, j);
      }
    }
    Mask[i] = mask;
  }
}
int solve(int i, int mask) {
  if (i >= n) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  long long ret = LLONG_MAX;
  int d;
  int d_tmp = -1;
  for (int j = 1; j <= 60; j++) {
    bool sorry = ((Mask[j] & mask) > 0);
    if (!sorry) {
      int tmp = mask | Mask[j];
      long long ret1 = abs(a[i] - j) + solve(i + 1, tmp);
      if (ret1 < ret) {
        ret = ret1;
        d_tmp = tmp;
        d = j;
      }
    }
  }
  if (d_tmp != -1) dir[i + 1][d_tmp] = 1;
  return dp[i][mask] = ret;
}
void print(int i, int mask) {
  int d_tmp = -1, ret = INT_MAX, d;
  for (int j = 1; j <= 60; j++) {
    bool sorry = ((Mask[j] & mask) > 0);
    if (!sorry) {
      int tmp = mask | Mask[j];
      long long ret1 = abs(a[i] - j) + dp[i + 1][tmp];
      if (ret1 < ret) {
        ret = ret1;
        d_tmp = tmp;
        d = j;
      }
    }
  }
  if (dir[i + 1][d_tmp]) {
    cout << d << " ";
    print(i + 1, d_tmp);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  seiveGen(100);
  factor();
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(0, 0);
  print(0, 0);
  return 0;
}
