#include <bits/stdc++.h>
using namespace std;
int n;
int a[101];
int dp[101][1 << 16];
int trans[101][1 << 16];
int val[61];
int ps[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int f(int cur, int mask) {
  if (cur > n) return 0;
  int &ret = dp[cur][mask];
  if (ret != -1) return ret;
  ret = 1000000;
  for (int i = 1; i <= 60; i++) {
    if ((val[i] & mask) == 0) {
      int v = f(cur + 1, mask | val[i]) + abs(a[cur] - i);
      if (v < ret) {
        ret = v;
        trans[cur][mask] = i;
      }
    }
  }
  return ret;
}
int main() {
  for (int i = 0; i <= 60; i++) {
    val[i] = 0;
    for (int j = 0; j < 16; j++)
      if (i % ps[j] == 0) val[i] |= (1 << j);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, 0xff, sizeof(dp));
  f(1, 0);
  int now = 0;
  for (int i = 1; i <= n; i++) {
    cout << trans[i][now] << " ";
    now |= val[trans[i][now]];
  }
}
