#include <bits/stdc++.h>
template <typename T>
void read(T &x);
template <typename T>
void read(T &x, T &y);
template <typename T>
void read(T &x, T &y, T &z);
template <typename T>
void write(T x);
template <typename T>
void writeC(T x);
template <typename T>
void writeN(T x);
int d[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int a[205], b[205], f[205][1 << 17], S[105], pre[205][1 << 17], n, v[1 << 17],
    tl;
void output(int x, int y) {
  if (x == 1) return;
  b[x - 1] = pre[x][y];
  output(x - 1, y ^ S[pre[x][y]]);
}
signed main() {
  std::memset(f, 63, sizeof(f));
  f[1][0] = 0;
  read(n);
  for (int i = 1; i <= (n); ++i) read(a[i]);
  ;
  for (int i = 1; i <= 60; ++i) {
    for (int j = 0; j < 16; ++j) {
      if (i % d[j] == 0) S[i] |= (1 << j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int mask = 0; mask < (1 << 16); ++mask) {
      for (int j = 1; j <= 60; ++j) {
        if (mask & S[j]) continue;
        int w = f[i][mask] + std::abs(j - a[i]);
        if (f[i + 1][mask | S[j]] > w) {
          f[i + 1][mask | S[j]] = w;
          pre[i + 1][mask | S[j]] = j;
        }
      }
    }
  }
  int y = 0, ans = 1e9;
  for (int mask = 0; mask < (1 << 17); ++mask) {
    if (f[n + 1][mask] < ans) {
      y = mask;
      ans = f[n + 1][mask];
    }
  }
  output(n + 1, y);
  for (int i = 1; i <= n; ++i) write(b[i]);
  return 0;
}
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  T flag = 1;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -flag;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= flag;
}
template <typename T>
void read(T &x, T &y) {
  read(x);
  read(y);
}
template <typename T>
void read(T &x, T &y, T &z) {
  read(x);
  read(y);
  read(z);
}
template <typename T>
void writeC(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) writeC(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void write(T x) {
  writeC(x);
  putchar(' ');
}
template <typename T>
void writeN(T x) {
  writeC(x);
  puts("");
}
