#include <bits/stdc++.h>
using namespace std;
int cnt;
int nn[100];
int p[100];
int f[110][131072];
int froma[110][131072];
int fromb[110][131072];
int mask[110];
int n;
int a[110];
void print(int step, int mask) {
  if (step == 0) return;
  print(step - 1, froma[step][mask]);
  printf("%i ", fromb[step][mask]);
}
int main() {
  for (int i = 2; i < 100; ++i)
    if (!nn[i]) {
      p[cnt++] = i;
      for (int j = i + i; j < 100; j += i) nn[j] = 1;
    }
  for (int i = 1; i <= 58; ++i) {
    for (int j = 0; j <= 15; ++j)
      if (i % p[j] == 0) mask[i] = mask[i] | (1 << j);
  }
  scanf("%i", &n);
  for (int i = 1; i <= n; ++i) scanf("%i", &a[i]);
  for (int i = 0; i < 110; ++i)
    for (int j = 0; j < 131072; ++j) f[i][j] = 16000;
  f[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 58; ++j) {
      int z = mask[j];
      int dt = abs(j - a[i]);
      for (int t = 0; t < 131072; ++t)
        if (!(t & z)) {
          if (f[i][t | z] > dt + f[i - 1][t]) {
            froma[i][t | z] = t;
            fromb[i][t | z] = j;
            f[i][t | z] = dt + f[i - 1][t];
          }
        }
    }
  }
  int ans = 0;
  for (int i = 0; i < 131072; ++i)
    if (f[n][i] < f[n][ans]) ans = i;
  print(n, ans);
  return 0;
}
