#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
long long n;
long long a[105];
long long factormask[59];
long long dp[105][1 << 16];
long long b[105][1 << 16];
long long calc(long long i, long long mask) {
  if (i == 0) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  dp[i][mask] = calc(i - 1, mask) + abs(a[i] - 1);
  b[i][mask] = 1;
  for (long long j = 2; j < 59; j++) {
    if ((mask & factormask[j]) != factormask[j]) continue;
    long long cur = calc(i - 1, mask ^ factormask[j]) + abs(a[i] - j);
    if (cur < dp[i][mask]) {
      dp[i][mask] = cur;
      b[i][mask] = j;
    }
  }
  return dp[i][mask];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long p[16] = {2,  3,  5,  7,  11, 13, 17, 19,
                     23, 29, 31, 37, 41, 43, 47, 53};
  for (long long i = 1; i < 59; i++) {
    for (long long j = 0; j < 16; j++) {
      if (i % p[j] == 0) {
        factormask[i] |= (1 << j);
      }
    }
  }
  memset(dp, -1, sizeof(dp));
  long long full_mask = ((1 << 16) - 1);
  calc(n, full_mask);
  long long mask = full_mask;
  vector<long long> ans;
  for (long long i = n; i >= 1; i--) {
    long long cur = b[i][mask];
    ans.push_back(cur);
    mask ^= factormask[cur];
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans) cout << x << " ";
}
