#include <bits/stdc++.h>
using namespace std;
const int INF = 3000;
void localFile() {
  freopen("cf.in", "r", stdin);
  freopen("cf.out", "w", stdout);
}
vector<int> primes;
int bitmatch[60], patterns[60];
bool sieve[60];
int p = 16;
vector<int> poss[1 << 16];
int n, a[101], d[101][1 << 16], b[101][1 << 16];
int main(void) {
  for (int i = 2; i < 59; i++) {
    if (sieve[i] == false) {
      primes.push_back(i);
      for (int j = i + i; j < 59; j += i) {
        sieve[j] = true;
      }
    }
  }
  for (int i = 0; i < (int)primes.size(); i++) {
    bitmatch[primes[i]] = i;
  }
  for (int num = 2; num < 59; num++) {
    int pattern = 0;
    for (int j = 0; j < p; j++) {
      int prime = primes[j];
      if (num % prime == 0) {
        pattern |= (1 << j);
      }
    }
    patterns[num] = pattern;
  }
  for (int i = 0; i < (1 << p); i++) {
    for (int j = 2; j < 59; j++) {
      if ((i & patterns[j]) == patterns[j]) {
        poss[i].push_back(j);
      }
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << p); j++) {
      d[i][j] = INF;
      b[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << p); j++) {
      d[i][j] = min(d[i][j], d[i - 1][j] + abs(a[i] - 1));
      b[i][j] = -1;
      for (int id = 0; id < (int)poss[j].size(); id++) {
        int num = poss[j][id];
        int pat = patterns[num];
        int jp = j - pat;
        if (d[i][j] > d[i - 1][jp] + abs(a[i] - num)) {
          d[i][j] = d[i - 1][jp] + abs(a[i] - num);
          b[i][j] = id;
        }
      }
    }
  }
  int minval = INF, st = -1;
  vector<int> ans;
  for (int j = 0; j < (1 << p); j++) {
    if (d[n][j] < minval) {
      minval = d[n][j];
      st = j;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (b[i][st] == -1) {
      ans.push_back(1);
    } else {
      ans.push_back(poss[st][b[i][st]]);
      st -= patterns[poss[st][b[i][st]]];
    }
  }
  for (int i = (int)ans.size() - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
