#include <bits/stdc++.h>
using namespace std;
bool vis[60];
vector<int> primes, v, ar[66];
int dp[105][(1 << 16) + 5];
int fact[105];
void sieve() {
  memset(vis, true, sizeof(vis));
  for (int i = 2; i <= 53; i++) {
    if (vis[i] == true) {
      for (int j = 2 * i; j <= 53; j += i) vis[j] = false;
      primes.push_back(i);
    }
  }
}
bool Check(int n, int pos) { return n & (1 << pos); }
int Set(int n, int pos) { return n | (1 << pos); }
int f(int i, int mask) {
  if (i == v.size()) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  int value = 1e7;
  for (int j = 1; j <= 53; j++) {
    int fac = j, now = mask;
    bool possible = true;
    for (int i1 = 0; i1 < ar[j].size(); i1++) {
      if (Check(now, ar[j][i1]) == true) {
        possible = false;
        break;
      }
      now = Set(now, ar[j][i1]);
    }
    if (possible == true) value = min(value, f(i + 1, now) + abs(v[i] - j));
  }
  return dp[i][mask] = value;
}
void pre() {
  for (int i = 2; i <= 53; i++) {
    int temp = i;
    for (int j = 0; primes[j] * primes[j] <= temp; j++) {
      if (temp % primes[j] == 0) {
        while (temp % primes[j] == 0) {
          temp /= primes[j];
        }
        ar[i].push_back(j);
      }
    }
    if (temp > 1) {
      for (int j = 0; j < primes.size(); j++) {
        if (primes[j] == temp) ar[i].push_back(j);
      }
    }
  }
}
int main(void) {
  sieve();
  int n;
  scanf("%d", &n);
  vector<int> temp(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp[i]);
    v.push_back(temp[i]);
  }
  pre();
  memset(dp, -1, sizeof(dp));
  int ans = f(0, 0), mask = 0, pre = 0;
  for (int i = 0; i < v.size(); i++) {
    int now = mask, val = 0;
    for (int j = 1; j <= 53; j++) {
      int fac = j;
      now = mask;
      bool possible = true;
      for (int k = 0; primes[k] * primes[k] <= fac; k++) {
        if (fac % primes[k] == 0) {
          while (fac % primes[k] == 0) {
            fac /= primes[k];
          }
          if (Check(now, k) == true) {
            possible = false;
            break;
          } else
            now = Set(now, k);
        }
      }
      if (possible == false) continue;
      if (fac > 1) {
        for (int i1 = 0; i1 < primes.size(); i1++) {
          if (primes[i1] == fac) {
            if (Check(now, i1) == true) possible = false;
            now = Set(now, i1);
          }
        }
      }
      if (possible == false) continue;
      val = f(i + 1, now);
      if (pre + val + abs(v[i] - j) == ans) {
        mask = now;
        pre += abs(v[i] - j);
        temp[i] = j;
        break;
      }
    }
  }
  for (auto it : temp) cout << it << " ";
  return 0;
}
