#include <bits/stdc++.h>
using namespace std;
const int N = 120;
vector<int> p;
const int inf = 0x3f3f3f3f;
int a[N], b[N], f[N][1 << 17], num[N][1 << 17], st[N];
int n;
vector<int> ans;
int main() {
  int i, j, k, all;
  for (i = 2; i <= 60; i++) {
    for (j = 2; j < i; j++)
      if (i % j == 0) break;
    if (j == i) {
      p.push_back(i);
    }
  }
  for (i = 1; i <= 60; i++) {
    for (j = 0; j < p.size(); j++)
      if (i % p[j] == 0) {
        st[i] |= 1 << j;
      }
  }
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(f, inf, sizeof(f));
  f[0][0] = 0;
  all = 1 << p.size();
  for (i = 1; i <= n; i++) {
    for (j = 0; j < all; j++)
      if (f[i - 1][j] < inf) {
        for (k = 1; k <= 60; k++) {
          if (!(j & st[k]) && f[i - 1][j] + abs(k - a[i]) < f[i][j | st[k]]) {
            f[i][j | st[k]] = f[i - 1][j] + abs(k - a[i]);
            num[i][j | st[k]] = k;
          }
        }
      }
  }
  int ansj = 0;
  for (j = 0; j < all; j++)
    if (f[n][ansj] > f[n][j]) ansj = j;
  j = ansj;
  for (i = n; i; i--) {
    ans.push_back(num[i][j]);
    j ^= st[num[i][j]];
  }
  reverse(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) {
    if (i) printf(" ");
    printf("%d", ans[i]);
  }
}
