#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int Size = 101;
const int INF = 0x3fffffff;
const int prime[] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                     29, 31, 37, 41, 43, 47, 53, 59, 61};
int n, a[Size], b[Size], d[Size];
int dp[Size][200001];
int ans[Size][200001];
void getdiv(int x) {
  int k = 0, fakeYumaAK = x;
  for (int i = 0; i <= 16; i++) {
    while (x % prime[i] == 0) {
      x /= prime[i];
      k = k | (1 << i);
    }
  }
  d[fakeYumaAK] = k;
}
void init() {
  for (int i = 1; i < Size; i++) getdiv(i);
  memset(ans, -1, sizeof(ans));
  ans[0][0] = 0;
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
}
void dfs(int deep, int now) {
  if (!deep) return;
  dfs(deep - 1, now ^ d[ans[deep][now]]);
  printf("%d ", ans[deep][now]);
}
int main() {
  init();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 65536; j++) {
      if (ans[i][j] != -1) {
        for (int k = 1; k < 60; k++) {
          if (j & d[k]) continue;
          int tt = j | d[k], pp = dp[i][j] + abs(k - a[i + 1]);
          if (ans[i + 1][tt] == -1 || pp < dp[i + 1][tt]) {
            ans[i + 1][tt] = k;
            dp[i + 1][tt] = pp;
          }
        }
      }
    }
  }
  int ppp = INF, last = 0;
  for (int i = 0; i < 65536; i++) {
    if (ans[n][i] != -1 && dp[n][i] < ppp) {
      ppp = dp[n][i];
      last = i;
    }
  }
  dfs(n, last);
  return 0;
}
