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 long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
long long int arr[100005];
long long int dp[105][1 << 17][2];
long long int prim[] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                        29, 31, 37, 41, 43, 47, 53, 59};
void solve() {
  long long int n;
  cin >> n;
  memset(dp, 1000000009, sizeof(dp));
  ;
  for (int i = 0; i < n; i++) cin >> arr[i];
  ;
  for (long long int i = 0; i < 1 << 17; ++i) {
    dp[0][i][0] = 0;
    dp[0][i][1] = -1LL;
  }
  for (long long int i = 1; i < n + 1; ++i) {
    for (long long int j = 1; j < 61; ++j) {
      long long int x = 0LL;
      for (long long int k = 0; k < 17; ++k) {
        if (j % (prim[k]) == 0) x += (1 << k);
      }
      long long int fac = (~x) & ((1 << 17) - 1);
      for (long long int k = fac;; k = (k - 1) & fac) {
        if (dp[i - 1][k][0] + abs(arr[i - 1] - j) < dp[i][k | x][0]) {
          dp[i][k | x][0] = dp[i - 1][k][0] + abs(arr[i - 1] - j);
          dp[i][k | x][1] = j;
        }
        if (k == 0) break;
      }
    }
    long long int mn = inf, pos = 0LL, t;
  }
  long long int mn = inf, pos = 0LL, t;
  for (long long int i = 0; i < 1 << 17; ++i) {
    if (mn > dp[n][i][0]) {
      mn = dp[n][i][0];
      pos = i;
      t = dp[n][i][1];
      ;
    }
  }
  vector<long long int> ans;
  long long int curr = n;
  while (curr != 0) {
    ans.push_back(dp[curr][pos][1]);
    long long int x = 0LL;
    for (long long int i = 0; i < 17; ++i) {
      if (dp[curr][pos][1] % (prim[i]) == 0) x += (1 << i);
    }
    pos = (~x) & pos;
    curr--;
  }
  reverse((ans).begin(), (ans).end());
  for (long long int it : ans) cout << it << " ";
  cout << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int tc = 1;
  while (tc--) {
    solve();
  }
}