#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
template <class T>
T sqr(T a) {
  return a * a;
}
int n, mi[60];
int m, a[105], b[100],
    ar[17] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int d[1 << 17][111];
pair<int, int> ot[1 << 17][111];
int oa[101];
void init() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < (1 << 17); ++i)
    for (int j = 0; j <= n; ++j) d[i][j] = 1e9;
  d[0][0] = 0;
  for (int i = 2; i < 60; ++i) {
    int t = 0;
    for (int j = 16; j >= 0; --j) {
      if (!(i % ar[j])) t |= 1;
      t <<= 1;
    }
    t /= 2;
    mi[i] = t;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < (1 << 17); ++j) {
      if (d[j][i] == 1e9) continue;
      for (int r = 1; r < 60; ++r) {
        if (mi[r] & j) continue;
        if (d[mi[r] | j][i + 1] >= d[j][i] + abs(a[i] - r)) {
          d[mi[r] | j][i + 1] = d[j][i] + abs(a[i] - r);
          ot[mi[r] | j][i + 1] = pair<int, int>(j, r);
        }
      }
    }
  }
  int o = 1e9;
  pair<int, int> to;
  for (int i = 0; i < (1 << 17); ++i) {
    if (o > d[i][n]) {
      o = d[i][n];
      to = ot[i][n];
    }
  }
  for (int i = n; i > 0; --i) {
    oa[i] = to.second;
    to = ot[to.first][i - 1];
  }
  for (int i = 1; i <= n; ++i) cout << oa[i] << ' ';
}
void solve() {}
int main() {
  init();
  solve();
  return 0;
}
