Problem: Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.

<image>

A sequence of positive integers bi is harmony if and only if for every two elements of the sequence their greatest common divisor equals 1. According to an ancient book, the key of the chest is a harmony sequence bi which minimizes the following expression:

<image>

You are given sequence ai, help Princess Twilight to find the key.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of elements of the sequences a and b. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 30).

Output

Output the key — sequence bi that minimizes the sum described above. If there are multiple optimal sequences, you can output any of them.

Examples

Input

5
1 1 1 1 1


Output

1 1 1 1 1 

Input

5
1 6 4 2 8


Output

1 5 3 1 8 

Solution (in CPP):

Solution:
#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 << " ";
}