#include <bits/stdc++.h>
using namespace std;
int n, a[101], p[60], pn;
int dp[101][1 << 17], d[61], out[101];
int par[101][1 << 17], num[101][1 << 17];
int main() {
  srand(time(0));
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 2; i <= 60; ++i) {
    bool good = true;
    for (int j = 2; j < i; ++j)
      if (i % j == 0) good = false;
    if (good) p[pn++] = i;
  }
  for (int i = 1; i <= 60; ++i) {
    d[i] = 0;
    for (int j = 0; j < pn; ++j)
      if (i % p[j] == 0) d[i] |= (1 << j);
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int k = 1; k <= 60; ++k) {
      int B = d[k];
      for (int mask = 0; mask < (1 << 17); ++mask) {
        int A = mask & ~B;
        int C = A | B;
        if (dp[i - 1][A] == -1) continue;
        if (dp[i][C] == -1 || dp[i - 1][A] + abs(a[i] - k) < dp[i][C]) {
          dp[i][C] = dp[i - 1][A] + abs(a[i] - k);
          par[i][C] = B;
          num[i][C] = k;
        }
      }
    }
  }
  int ans = (1 << 30), cur;
  for (int mask = 0; mask < (1 << 17); ++mask) {
    if (dp[n][mask] == -1) continue;
    if (ans > dp[n][mask]) {
      ans = dp[n][mask];
      cur = mask;
    }
  }
  int x = n;
  while (x > 0) {
    out[x] = num[x][cur];
    cur &= ~par[x][cur];
    --x;
  }
  for (int i = 1; i <= n; ++i) printf("%d ", out[i]);
  return 0;
}
