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;
bool isPrime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return 0;
  return 1;
}
int mk[1000], a[1000];
pair<int, int> d[1000];
int dp[19][1 << 19], p[19][1 << 19];
int answer[1000];
vector<int> pr;
int get(int mask) {
  int num = 0;
  for (int i = 0; i < 17; i++)
    if (mask & (1 << i)) num += pr[i];
  return num;
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i], d[i] = make_pair(a[i], i);
  sort(d, d + N);
  reverse(d, d + N);
  for (int i = 2; i <= 60; i++)
    if (isPrime(i)) pr.push_back(i);
  for (int i = 1; i <= 60; i++)
    for (int j = 0; j < pr.size(); j++)
      if (i % pr[j] == 0) mk[i] ^= (1 << j);
  for (int i = 0; i <= 18; i++)
    for (int mask = 0; mask < (1 << 18); mask++) dp[i][mask] = ((1 << 30) - 1);
  dp[0][0] = 0;
  for (int i = 0; i < min(N, 17); i++)
    for (int mask = 0; mask < (1 << 17); mask++) {
      for (int next = 1; next <= 60; next++) {
        if ((mk[next] & mask) == 0) {
          int newdp = dp[i][mask] + abs(d[i].first - next);
          if (dp[i + 1][mask ^ mk[next]] > newdp) {
            dp[i + 1][mask ^ mk[next]] = newdp;
            p[i + 1][mask ^ mk[next]] = next;
          }
        }
      }
    }
  int best = ((1 << 30) - 1);
  int MASK = -1;
  for (int mask = 0; mask < (1 << 17); mask++)
    if (best > dp[min(N, 17)][mask]) {
      best = dp[min(N, 17)][mask];
      MASK = mask;
    }
  int I = min(N, 17);
  while (I) {
    int back = p[I][MASK];
    answer[d[I - 1].second] = back;
    MASK ^= mk[back];
    I--;
  }
  for (int i = min(N, 17); i < N; i++) answer[d[i].second] = 1;
  for (int i = 0; i < N; i++) cout << answer[i] << " ";
  cout << endl;
}