#include <bits/stdc++.h>
using namespace std;
const int primes[17] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                        29, 31, 37, 41, 43, 47, 53, 59};
int N, A[110], dp[110][1 << 17], s[60];
const int Field = 0x1FFFF;
int main() {
  scanf("%d", &N);
  int i;
  for (i = 0; i <= N - 1; i++) scanf("%d", &A[i]);
  for (i = 1; i <= 59; i++) s[i] = 0;
  for (i = 0; i <= 16; i++)
    for (int j = primes[i]; j < 60; j += primes[i]) s[j] |= 1 << i;
  int j, k;
  for (i = 0; i <= N; i++)
    for (j = 0; j <= Field; j++) dp[i][j] = 0x23333333;
  dp[0][0] = 0;
  for (i = 0; i <= N - 1; i++)
    for (k = 1; k <= 59; k++)
      for (int f = j = (Field ^ s[k]);; j = (j - 1) & f) {
        dp[i + 1][j ^ s[k]] =
            min(dp[i + 1][j ^ s[k]], dp[i][j] + abs(A[i] - k));
        if (j == 0) break;
      }
  vector<int> RET;
  RET.clear();
  int ans = 0x23333333;
  int lv, u = 0;
  for (i = 0; i <= Field; i++)
    if (ans > dp[N][i]) {
      ans = dp[N][i];
      u = i;
    }
  for (lv = N - 1; lv >= 0; lv--)
    for (k = 1; k <= 59; k++)
      if (((u & s[k]) == s[k]) &&
          (dp[lv][u ^ s[k]] + abs(k - A[lv]) == dp[lv + 1][u])) {
        RET.push_back(k);
        u ^= s[k];
        break;
      }
  for (i = 1; i <= N; i++) printf("%d%s", RET[N - i], (i == N) ? "\n" : " ");
}
