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;
const int MAX_ELEMENT = 61;
const int MAXN = 101;
const int INF = 1E9;
const int NUMBER_OF_PRIMES = 16;
const int NUMBER_OF_MASK = (1 << NUMBER_OF_PRIMES) + 1;
const int primes[NUMBER_OF_PRIMES] = {2,  3,  5,  7,  11, 13, 17, 19,
                                      23, 29, 31, 37, 41, 43, 47, 53};
int mask_numbers[61];
int best_price[MAXN][NUMBER_OF_MASK];
int last_element[MAXN][NUMBER_OF_MASK];
int main() {
  int i, j, k;
  int val, mask;
  int N;
  cin >> N;
  vector<int> a(N);
  for (i = 0; i < N; i++) cin >> a[i];
  for (i = 1; i < MAX_ELEMENT; i++) {
    mask_numbers[i] = 0;
    for (j = 0; j < NUMBER_OF_PRIMES; j++)
      if (i % primes[j] == 0) mask_numbers[i] |= (1 << j);
  }
  best_price[0][0] = 0;
  for (mask = 1; mask < NUMBER_OF_MASK; mask++) best_price[0][mask] = INF;
  for (i = 1; i <= N; i++) {
    for (mask = 0; mask < NUMBER_OF_MASK; mask++) best_price[i][mask] = INF;
    for (val = 1; val < MAX_ELEMENT; val++) {
      for (mask = 0; mask < NUMBER_OF_MASK; mask++) {
        if ((mask & mask_numbers[val]) == mask_numbers[val] &&
            best_price[i][mask] > best_price[i - 1][mask ^ mask_numbers[val]] +
                                      abs(val - a[i - 1])) {
          best_price[i][mask] =
              best_price[i - 1][mask ^ mask_numbers[val]] + abs(val - a[i - 1]);
          last_element[i][mask] = val;
        }
      }
    }
  }
  int best_mask = 0;
  for (mask = 0; mask < NUMBER_OF_MASK; mask++)
    if (best_price[N][mask] < best_price[N][best_mask]) best_mask = mask;
  vector<int> ans(N);
  for (i = N; i > 0; i--) {
    ans[i - 1] = last_element[i][best_mask];
    best_mask ^= mask_numbers[ans[i - 1]];
  }
  for (i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
}