#include <bits/stdc++.h>
using namespace std;
struct point {
  int num, id;
};
int n, b[101], temp[101], ans, mid, vis[60], cnt, ccnt;
bool g[60][60];
point a[101];
bool cmp(point x, point y) { return x.num < y.num; }
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
void doit(int deep) {
  for (int i = deep + 1; i <= 58; i++)
    if (g[deep][i] && !vis[i]) vis[i] = deep;
}
void clear(int deep) {
  for (int i = deep; i <= 58; i++)
    if (vis[i] == deep) vis[i] = 0;
}
void calc() {
  for (int i = n - cnt; i >= 1; i--) temp[i] = 1;
  int flag = 1;
  for (int i = n - cnt + 1; i <= n; i++) {
    while (flag < 58) {
      flag++;
      if (vis[flag] == flag) {
        temp[i] = flag;
        break;
      }
    }
  }
  mid = 0;
  for (int i = 1; i <= n; i++) mid += (abs(a[i].num - temp[i]));
  if (mid < ans) {
    ans = mid;
    for (int i = 1; i <= n; i++) b[i] = temp[i];
    ccnt = cnt;
  }
}
void dfs(int deep) {
  if (cnt == n) {
    calc();
    return;
  }
  if (deep == 59) {
    calc();
    return;
  }
  dfs(deep + 1);
  if (!vis[deep]) {
    vis[deep] = deep;
    cnt++;
    doit(deep);
    dfs(deep + 1);
    cnt--;
    clear(deep);
  }
}
int main() {
  for (int i = 1; i <= 60; i++)
    for (int j = i + 1; j <= 60; j++)
      if (gcd(i, j) > 1)
        g[i][j] = 1;
      else
        g[i][j] = 0;
  ans = 0;
  memset(vis, 0, sizeof(vis));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].num;
    b[i] = 1;
    a[i].id = i;
    ans += a[i].num - b[i];
  }
  sort(a + 1, a + n + 1, cmp);
  cnt = 0;
  dfs(2);
  for (int i = 1; i <= n; i++) temp[a[i].id] = b[i];
  for (int i = 1; i <= n; i++) cout << temp[i] << " ";
  cout << endl;
  return 0;
}
