#include <bits/stdc++.h>
using namespace std;
struct num {
  int x, y;
};
num a[109];
int p[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53},
    d[109][150000], c[109][150000], ans, n, i, f[60];
bool srt(num a, num b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool srt2(num a, num b) { return a.y < b.y; }
int fun(int x) {
  if (f[x] != -1) return f[x];
  f[x] = 0;
  for (int i = 0; i < 16 && p[i] <= x; i++)
    if (x % p[i] == 0) f[x] |= (1 << i);
  return f[x];
}
int dp(int i, int m) {
  if (i == n) return 0;
  if (d[i][m] != -1) return d[i][m];
  d[i][m] = a[i].x - 1 + dp(i + 1, m);
  c[i][m] = 1;
  if (a[i].x == 1) return d[i][m];
  for (int j = 2; j <= 53; j++)
    if (!(m & fun(j)) && abs(j - a[i].x) + dp(i + 1, m | fun(j)) < d[i][m]) {
      d[i][m] = abs(j - a[i].x) + dp(i + 1, m | fun(j));
      c[i][m] = j;
    }
  return d[i][m];
}
void dp2(int i, int m) {
  if (i == n) return;
  if (c[i][m] == 1) {
    cout << "1 ";
    dp2(i + 1, m);
    return;
  }
  cout << c[i][m] << " ";
  dp2(i + 1, m | fun(c[i][m]));
}
int main() {
  memset(d, -1, sizeof d);
  memset(f, -1, sizeof f);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].x;
    a[i].y = i;
  }
  if (n > 16) {
    sort(a, a + n, srt);
    for (i = 0; i < n - 16; i++) {
      ans += a[i].x - 1;
      a[i].x = 1;
    }
    sort(a, a + n, srt2);
  }
  ans += dp(0, 0);
  dp2(0, 0);
  return 0;
}
