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 N = 100 + 10;
int a[N], n, d[65], dp[N][(1 << 17) + 10];
pair<int, int> par[N][(1 << 17) + 10];
vector<int> prime, ans;
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; ++i) cin >> a[i];
  bool flag;
  for (int i = 2; i < 61; ++i) {
    flag = false;
    for (int j = 2; j < i; ++j) flag |= (i % j == 0);
    if (!flag) prime.push_back(i);
  }
  for (int i = 1; i < 60; ++i) {
    for (int j = 0; j < prime.size(); ++j)
      if (i % prime[j] == 0) d[i] += (1 << j);
  }
  for (int i = 1; i < N; ++i)
    for (int j = 0; j < (1 << 17) + 5; ++j) dp[i][j] = 1e9;
  int forb;
  for (int i = 1; i < n + 1; ++i) {
    for (int last = 1; last < 60; ++last) {
      forb = 0;
      for (int j = 0; j < 17; ++j)
        if ((d[last] >> j & 1) == 0) forb += (1 << j);
      for (int mask = forb; mask != 0; mask = (mask - 1) & forb)
        if (dp[i][mask | d[last]] > dp[i - 1][mask] + abs(last - a[i])) {
          dp[i][mask | d[last]] = dp[i - 1][mask] + abs(last - a[i]);
          par[i][mask | d[last]].first = last;
          par[i][mask | d[last]].second = mask;
        }
    }
  }
  int now = 0;
  for (int mask = 1; mask < (1 << 17); ++mask)
    if (dp[n][mask] < dp[n][now]) now = mask;
  for (int i = n; i > 0; --i) {
    ans.push_back(par[i][now].first);
    now = par[i][now].second;
  }
  for (int i = ans.size() - 1; i > -1; --i) cout << ans[i] << ' ';
}