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;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i) {
    if (i != v.begin()) os << ", ";
    os << *i;
  }
  os << "]";
  return os;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> A(n);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", &A[i]);
  const int MAXB = 60;
  vector<bool> is_prime(MAXB + 1, true);
  is_prime[0] = is_prime[1] = false;
  vector<int> P;
  for (int i = (int)(2); i <= (int)(MAXB); ++i)
    if (is_prime[i]) {
      P.push_back(i);
      for (int j = 2 * i; j <= MAXB; j += i) is_prime[j] = false;
    }
  vector<int> mask(MAXB + 1, 0);
  for (int i = (int)(1); i <= (int)(MAXB); ++i)
    for (int j = 0; j < (int)(((int)((P).size()))); ++j)
      if (i % P[j] == 0) mask[i] |= (1 << j);
  vector<vector<int> > F(1 << ((int)((P).size())));
  for (int i = 0; i < (int)(1 << ((int)((P).size()))); ++i)
    for (int j = (int)(1); j <= (int)(MAXB); ++j)
      if (!(i & mask[j])) F[i].push_back(j);
  vector<vector<int> > D(n + 1,
                         vector<int>(1 << ((int)((P).size())), 1023456789));
  D[0][0] = 0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(1 << ((int)((P).size()))); ++j)
      if (D[i][j] < 1023456789)
        for (__typeof((F[j]).begin()) k = (F[j]).begin(); k != (F[j]).end();
             ++k) {
          int nj = j | mask[*k];
          D[i + 1][nj] = min(D[i + 1][nj], D[i][j] + abs(*k - A[i]));
        }
  vector<int> B(n);
  int x = distance(D[n].begin(), min_element(D[n].begin(), D[n].end()));
  for (int i = (int)(n - 1); i >= (int)(0); --i) {
    for (int k = (int)(1); k <= (int)(MAXB); ++k)
      if ((x & mask[k]) == mask[k]) {
        int px = x & ~mask[k];
        if (D[i][px] + abs(k - A[i]) == D[i + 1][x]) {
          B[i] = k;
          x = px;
          break;
        }
      }
  }
  for (int i = 0; i < (int)(n); ++i) printf(" %d" + (i == 0), B[i]);
  printf("\n");
}