#include <bits/stdc++.h>
using namespace std;
int dp[105][150005], tk[105], po2[25];
int arrbt[105][150005], vl[105][150005], p[105], pr[105];
vector<int> pri;
vector<int> kn[150005], cals, pv[150000];
map<int, int> mp;
void re(int cur, int val, int bm) {
  if (val > 60) {
    return;
  }
  if (mp[val] == 0) {
    kn[bm].push_back(val);
  }
  mp[val] = 1;
  re(cur, val * pri[cur], bm | po2[cur]);
  if (cur + 1 < pri.size()) re(cur + 1, val, bm);
}
void ss(int bm, int lv) {
  if (lv == pri.size()) {
    return;
  }
}
int main() {
  po2[0] = 1;
  for (int i = 1; i < 22; i++) {
    po2[i] = po2[i - 1] * 2;
  }
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 2; i <= 60; i++) {
    if (pr[i] == 0) {
      for (int j = 2 * i; j <= 100; j += i) {
        pr[j] = 1;
      }
      pri.push_back(i);
    }
  }
  re(0, 1, 0);
  for (int i = 0; i < 150005; i++) {
    if (!kn[i].empty()) {
      cals.push_back(i);
    }
  }
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 150005; j++) dp[i][j] = 1e9;
  }
  dp[0][0] = 0;
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < 150005; j++) {
      if (dp[i][j] != 1e9) {
        for (int k = 0; k < cals.size(); k++) {
          if ((cals[k] & j) == 0) {
            int pos = cals[k];
            for (int l = 0; l < kn[pos].size(); l++) {
              if (dp[i + 1][j | pos] > dp[i][j] + abs(kn[pos][l] - p[i])) {
                dp[i + 1][j | pos] = dp[i][j] + abs(kn[pos][l] - p[i]);
                arrbt[i + 1][j | pos] = j;
                vl[i + 1][j | pos] = kn[pos][l];
              }
            }
          }
        }
      }
    }
  }
  int mn = 1e9, pos = -1;
  int cc = t, cc2 = cc;
  for (int i = 0; i < 150005; i++) {
    if (mn > dp[cc2][i]) {
      mn = dp[cc2][i];
      pos = i;
    }
  }
  while (cc > 0) {
    tk[cc] = vl[cc][pos];
    pos = arrbt[cc][pos];
    cc--;
  }
  for (int i = 1; i <= cc2; i++) {
    printf("%d ", tk[i]);
  }
}
