#include <bits/stdc++.h>
using namespace std;
int bit[75];
vector<int> prime;
int p[100];
int a[105];
int dp[105][1 << 17];
int n;
inline void pre() {
  for (int i = 2; i < 60; i++) {
    if (!p[i]) {
      prime.push_back(i);
      for (int j = i + i; j < 60; j += i) {
        p[j] = 1;
      }
    }
  }
  for (int num = 1; num < 60; num++) {
    for (int j = 0; j < prime.size(); j++) {
      if (prime[j] > num) {
        break;
      }
      if (num % prime[j] == 0) {
        bit[num] |= (1 << j);
      }
    }
  }
}
int res[105];
int rec(int pos, int mask) {
  if (pos >= n) {
    return 0;
  }
  if (dp[pos][mask] != -1) {
    return dp[pos][mask];
  }
  int ans = 1000000007;
  int val = -1;
  for (int i = 1; i < 60; i++) {
    int sum = abs(a[pos] - i);
    int nmask = bit[i];
    if (!(nmask & mask)) {
      sum += rec(pos + 1, mask | nmask);
      ans = min(ans, sum);
    }
  }
  return dp[pos][mask] = ans;
}
inline void solve(int pos, int mask) {
  if (pos >= n) {
    return;
  }
  int val = -1;
  int nxtmask = -1;
  int ans = 1000000007;
  for (int i = 1; i < 60; i++) {
    int sum = abs(a[pos] - i);
    int nmask = bit[i];
    if (!(nmask & mask)) {
      sum += rec(pos + 1, mask | nmask);
      if (sum < ans) {
        ans = sum;
        val = i;
        nxtmask = mask | nmask;
      }
    }
  }
  cout << val << " ";
  solve(pos + 1, nxtmask);
}
int main() {
  pre();
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  ;
  rec(0, 0);
  solve(0, 0);
}
