#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  x *= f;
}
const int prime[16] = {2,  3,  5,  7,  11, 13, 17, 19,
                       23, 29, 31, 37, 41, 43, 47, 53};
int n, a[105];
int f[105][1 << 17], tab[65], pre[105][1 << 17];
inline void print(int x, int S) {
  if (!pre[x][S]) return;
  print(x - 1, S ^ tab[pre[x][S]]);
  printf("%d ", pre[x][S]);
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= 59; ++i)
    for (int j = 0; j < 16; ++j)
      if (!(i % prime[j])) tab[i] ^= (1 << j);
  for (int i = 1; i <= n; ++i)
    for (int S = 0; S < (1 << 16); ++S) {
      f[i][S] = 0x3f3f3f3f;
      for (int j = 1; j <= 58; ++j) {
        if ((tab[j] | S) != S) continue;
        int tmp = abs(a[i] - j) + f[i - 1][S ^ tab[j]];
        if (tmp < f[i][S]) {
          f[i][S] = tmp;
          pre[i][S] = j;
        }
      }
    }
  print(n, (1 << 16) - 1);
  return 0;
}
