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>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const int INF = 1000000000;
const int MAX = 128;
const int MAX2 = 61;
const int BASE = 1000000000;
int n, m;
int A[MAX];
vector<pair<int, int> > AA;
int M[MAX];
int E[MAX];
int R[MAX][1 << 17];
pair<int, int> Q[MAX][1 << 17];
vector<int> P;
bool Prime(int x) {
  for (int i = 2; i < x; ++i)
    if (x % i == 0) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &A[i]);
    AA.push_back(make_pair(A[i], i));
  }
  sort(AA.begin(), AA.end());
  sort(A, A + n);
  reverse(A, A + n);
  for (int i = (2); i < (MAX2); ++i)
    if (Prime(i)) P.push_back(i);
  m = (int)P.size();
  for (int i = (1); i < (MAX2); ++i) {
    for (int j = (0); j < (m); ++j)
      if (i % P[j] == 0) M[i] |= (1 << j);
  }
  for (int i = (0); i < (MAX); ++i)
    for (int j = (0); j < ((1 << m)); ++j) {
      R[i][j] = INF;
      Q[i][j] = make_pair(-1, -1);
    }
  R[0][0] = 0;
  int cnt = 0;
  for (int i = (0); i < (n); ++i)
    for (int mask = (0); mask < ((1 << m)); ++mask) {
      if (R[i][mask] == INF) continue;
      int up = MAX2;
      if (i > m + 1) up = 2;
      for (int j = (1); j < (up); ++j) {
        if ((mask & M[j]) == 0)
          if (R[i][mask] + abs(j - A[i]) < R[i + 1][mask | M[j]]) {
            R[i + 1][mask | M[j]] = R[i][mask] + abs(j - A[i]);
            Q[i + 1][mask | M[j]] = make_pair(mask, j);
          }
      }
    }
  vector<int> Res;
  int res = INF;
  int mask = 0;
  for (int i = (0); i < ((1 << m)); ++i)
    if (R[n][i] < res) {
      res = R[n][i];
      mask = i;
    }
  int pos = n;
  while (pos > 0) {
    pair<int, int> p = Q[pos][mask];
    Res.push_back(p.second);
    pos = pos - 1;
    mask = p.first;
  }
  for (int i = (0); i < ((int)Res.size()); ++i) E[AA[i].second] = Res[i];
  for (int i = (0); i < (n); ++i) printf("%d%c", E[i], i + 1 == n ? '\n' : ' ');
  return 0;
}