#include <bits/stdc++.h>
using namespace std;
int xx[4] = {0, 0, 1, -1};
int yy[4] = {1, -1, 0, 0};
int n;
int a[int(1e2 + 10)];
int f[int(1e2 + 10)][((1 << 17) - 1) + 10];
pair<int, int> trace[int(1e2 + 10)][((1 << 17) - 1) + 10];
bool fr[int(1e2 + 10)];
int dem;
int x[int(1e2 + 10)], t[int(1e2 + 10)], c[int(1e2 + 10)], fact[int(1e2 + 10)];
int biton(int x, int i) { return x | (1 << i); }
int main() {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; i++) scanf("%d", &a[i]);
  memset(f, 63, sizeof(f));
  int def = f[0][0];
  memset(fr, true, sizeof(fr));
  for (int i = (2), _b = (60); i <= _b; i++)
    if (fr[i]) {
      dem++;
      x[dem - 1] = i;
      t[i] = dem - 1;
      for (int j = (1), _b = (60 / i); j <= _b; j++) {
        c[i * j] = i;
        fr[i * j] = false;
      }
    }
  for (int i = (2), _b = (60); i <= _b; i++) {
    fact[i] = biton(fact[i / c[i]], t[c[i]]);
  }
  f[0][0] = 0;
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int x = (1), _b = (60); x <= _b; x++) {
      int ss = ((1 << 17) - 1) & (~fact[x]);
      for (int s = ss;; s = (s - 1) & ss) {
        int s2 = s | fact[x];
        if (f[i][s2] > f[i - 1][s] + abs(a[i] - x)) {
          f[i][s2] = f[i - 1][s] + abs(a[i] - x);
          trace[i][s2].first = s;
          trace[i][s2].second = x;
        }
        if (s == 0) break;
      }
    }
  }
  int v = 0;
  int res = def;
  for (int s = (0), _b = (((1 << 17) - 1)); s <= _b; s++)
    if (f[n][s] < res) {
      res = f[n][s];
      v = s;
    }
  int r[int(1e2 + 10)];
  for (int i = (n), _a = (1); i >= _a; i--) {
    r[i] = trace[i][v].second;
    v = trace[i][v].first;
  }
  for (int i = (1), _b = (n); i <= _b; i++) printf("%d ", r[i]);
}
