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 = 17;
int dp[101][1 << N];
int prost[60], msk[60];
signed main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, c = 0;
  vector<int> pressf{0};
  cin >> n;
  for (int i = 1; i < 60; i++) {
    bool t = 1;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) t = 0;
    }
    if (t && i != 1) prost[i] = c++;
  }
  for (int i = 1; i < 60; i++) {
    int i1 = i;
    for (int j = 2; j * j <= i; j++) {
      while (i % j == 0) msk[i1] |= (1 << prost[j]), i /= j;
    }
    if (i > 1) msk[i1] |= (1 << prost[i]);
    i = i1;
  }
  for (int i = 0; i <= n; i++) {
    for (int mask = 0; mask < (1 << 17); mask++) dp[i][mask] = 1e9;
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    pressf.push_back(a);
    for (int j = 1; j < 60; j++) {
      int r = abs(a - j);
      int f = msk[j];
      int x = (~msk[j]) & ((1 << 17) - 1);
      for (int s = x;; s = (s - 1) & x) {
        if (dp[i][s | f] > dp[i - 1][s] + r) dp[i][s | f] = dp[i - 1][s] + r;
        if (!s) break;
      }
    }
  }
  pair<int, int> minans = {1e9, 1e9};
  for (int i = 0; i < (1 << 17); i++) minans = min(minans, {dp[n][i], i});
  int v = minans.second;
  vector<int> kek;
  for (int i = n; i > 0; i--) {
    for (int j = 1; j < 60; j++) {
      if ((v ^ msk[j]) == v - msk[j] &&
          dp[i][v] == dp[i - 1][v ^ msk[j]] + abs(pressf[i] - j)) {
        v ^= msk[j];
        kek.push_back(j);
        break;
      }
    }
  }
  reverse(kek.begin(), kek.end());
  for (auto i : kek) cout << i << " ";
}