#include <bits/stdc++.h>
using namespace std;
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int tem, n, k, i, flag, j;
int a[102], key[65], ok[102], ans[102][1 << 16], f[102][1 << 16];
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i < 59; i++)
    for (j = 0; j < 16; j++)
      if (i % p[j] == 0) key[i] |= (1 << j);
  memset(f, 60, sizeof(f));
  f[0][0] = 0;
  for (i = 1; i <= n; i++)
    for (j = 0; j < 1 << 16; j++)
      if (f[i - 1][j] <= 200000000)
        for (k = 1; k < 59; k++)
          if (!(j & key[k]))
            if (f[i][j | key[k]] > f[i - 1][j] + abs(k - a[i])) {
              f[i][j | key[k]] = f[i - 1][j] + abs(k - a[i]);
              ans[i][j | key[k]] = k;
            }
  tem = 200000000;
  for (i = 0; i < 1 << 16; i++)
    if (f[n][i] < tem) {
      flag = i;
      tem = f[n][i];
    }
  for (i = n; i; i--) {
    ok[i] = ans[i][flag];
    flag = flag ^ key[ok[i]];
  }
  printf("%d", ok[1]);
  for (i = 2; i <= n; i++) printf(" %d", ok[i]);
  printf("\n");
  return 0;
}
