#include <bits/stdc++.h>
using namespace std;
inline int read_int() {
  register char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int ret = 0;
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return ret;
}
inline void fastwrite(int a) {
  char snum[20];
  int i = 0;
  do {
    snum[i++] = a % 10 + 48;
    a = a / 10;
  } while (a != 0);
  i = i - 1;
  while (i >= 0) putchar(snum[i--]);
  putchar('\n');
}
const long long int mod = 1000000007;
int n;
int dp[(1 << 16) + 1][101], ans1[(1 << 16) + 1][101], ans2[(1 << 16) + 1][101];
int ans[101];
int arr[101];
vector<int> primes;
int factors[60];
int solve(int mask, int cur) {
  if (dp[mask][cur] != -1) return dp[mask][cur];
  if (cur == n) return 0;
  dp[mask][cur] = 10000001;
  int res;
  for (int j = 1; j < 58; ++j) {
    if ((factors[j] & mask)) continue;
    res = abs(arr[cur] - j) + solve(mask | factors[j], cur + 1);
    if (res < dp[mask][cur]) {
      dp[mask][cur] = res;
      ans1[mask][cur] = j;
      ans2[mask][cur] = (mask | factors[j]);
    }
  }
  return dp[mask][cur];
}
int main() {
  memset(dp, -1, sizeof dp);
  for (int i = 2; i < 60; ++i) {
    bool flag = 0;
    for (int j = 2; j < i; ++j)
      if (i % j == 0) {
        flag = 1;
        break;
      }
    if (flag == 0) primes.push_back(i);
  }
  for (int i = 2; i < 60; i++) {
    for (int j = 0; j < primes.size() && primes[j] <= i; ++j) {
      if (i % primes[j] == 0) factors[i] += (1 << j);
    }
  }
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int anss = solve(0, 0), box = 0;
  for (int i = 0; i < n; i++) {
    printf("%d ", ans1[box][i]);
    box = ans2[box][i];
  }
  return 0;
}
