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;
int n;
int A[150];
int primes[18] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                  29, 31, 37, 41, 43, 47, 53, 59};
int factors[70];
int memo[1 << 18][101];
short track[1 << 18][101];
long long dp(int factors_mask, int pos) {
  if (pos >= n) return 0;
  if (memo[factors_mask][pos] != -1) return memo[factors_mask][pos];
  long long res = 999999999;
  for (int k = 1; k <= 60; k++) {
    int mask = factors[k];
    if ((mask & factors_mask) == 0) {
      int new_mask = mask | factors_mask;
      int res1 = dp(new_mask, pos + 1) + abs(A[pos] - k);
      if (res1 < res) {
        res = res1;
        track[factors_mask][pos] = k;
      }
    }
  }
  return memo[factors_mask][pos] = res;
}
int factorize(int num) {
  int divisor = 0;
  int divmask = 0;
  while (num > 1) {
    int expo = 0;
    while (num % primes[divisor] == 0) num /= primes[divisor], expo++;
    if (expo > 0) divmask = (divmask | (1 << divisor));
    divisor++;
  }
  return divmask;
}
vector<long long> back_track() {
  int pos = 0;
  int mask = 0;
  vector<long long> V;
  while (pos < n) {
    long long x = track[mask][pos];
    V.push_back(x);
    mask = mask | factors[x];
    pos++;
  }
  return V;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int k = 0; k < n; k++) cin >> A[k];
  for (int k = 1; k <= 60; k++) factors[k] = factorize(k);
  memset(memo, -1, sizeof(memo));
  dp(0, 0);
  vector<long long> ans = back_track();
  for (int k = 0; k < ans.size(); k++) cout << ans[k] << " ";
  cout << endl;
  return 0;
}