#include <bits/stdc++.h>
using namespace std;
int masks[61];
int primes[10001];
int dp[101][1 << 17];
int n;
int values[101];
int func(int idx, int mask) {
  if (idx == n) {
    return 0;
  } else {
    int &ans = dp[idx][mask];
    if (ans == -1) {
      ans = 0xffffff;
      for (int i = 1; i <= 60; i++) {
        if ((mask & masks[i]) == 0) {
          ans = min(abs(values[idx] - i) + func(idx + 1, mask | masks[i]), ans);
        }
      }
    }
    return ans;
  }
}
void path(int idx, int mask) {
  if (idx == n) {
    return;
  } else {
    int ans = 0xffffff, idxT = 0;
    for (int i = 1; i <= 60; i++) {
      if ((mask & masks[i]) == 0) {
        if (abs(values[idx] - i) + func(idx + 1, mask | masks[i]) < ans) {
          ans = abs(values[idx] - i) + func(idx + 1, mask | masks[i]);
          idxT = i;
        }
      }
    }
    cout << idxT << " ";
    path(idx + 1, mask | masks[idxT]);
  }
}
int main(void) {
  for (int i = 0; i < 10000; i++) primes[i] = 1;
  primes[0] = primes[1] = 0;
  vector<int> p;
  for (int i = 2; i < 10000; i++) {
    if (primes[i]) {
      p.push_back(i);
      for (int j = 2 * i; j < 10000; j += i) {
        primes[j] = 0;
      }
    }
  }
  for (int i = 2; i <= 60; i++) {
    int mask = 0, tmp = i, idx = 0;
    while (tmp > 1) {
      if (idx < p.size() && tmp % p[idx] == 0) {
        tmp /= p[idx];
        mask |= (1 << idx);
      } else {
        idx++;
      }
    }
    masks[i] = mask;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> values[i];
  }
  memset(dp, -1, sizeof(dp));
  path(0, 0);
  return 0;
}
