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 maxn = 111111;
vector<int> vec[66];
int n, cnt, prime[66], gen[66], arr[111], brr[111], dp[111][1 << 17];
bool isGood(int num, int mask) {
  for (int i = 0; i < vec[num].size(); ++i) {
    if (mask & (1 << prime[vec[num][i]])) return false;
  }
  return true;
}
void foo() {
  for (int i = 2; i < 60; ++i) {
    bool isPrime = true;
    for (int j = 2; j * j <= i; ++j) {
      if (i % j == 0) isPrime = false;
    }
    if (isPrime) prime[i] = cnt++;
  }
  for (int i = 2; i < 60; ++i) {
    for (int j = 2; j < 60; ++j) {
      if (prime[j] != -1 && i % j == 0)
        vec[i].push_back(j), gen[i] |= (1 << prime[j]);
    }
  }
}
int solve(int idx, int mask) {
  if (idx == n) return dp[idx][mask] = 0;
  if (dp[idx][mask] != -1) return dp[idx][mask];
  int ret = INT_MAX;
  for (int i = 1; i < 60; ++i) {
    if (isGood(i, mask))
      ret = min(ret, abs(arr[idx] - i) + solve(idx + 1, mask | gen[i]));
  }
  return dp[idx][mask] = ret;
}
void go(int mn, int idx, int mask) {
  for (int i = 1; i < 60; ++i) {
    if (isGood(i, mask) &&
        dp[idx + 1][mask | gen[i]] == mn - abs(arr[idx] - i)) {
      brr[idx] = i;
      return go(mn - abs(arr[idx] - i), idx + 1, mask | gen[i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof(dp));
  memset(prime, -1, sizeof(prime));
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  foo();
  solve(0, 0);
  go(dp[0][0], 0, 0);
  for (int i = 0; i < n; ++i) cout << brr[i] << " ";
  cout << endl;
  return 0;
}