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 = 1e2 + 20, lg = (1 << (17)), maxm = 60 + 1, inf = 1e8;
vector<int> primes, a;
int b[maxn][lg], dp[maxn][lg];
int factors[maxn], mark[maxm];
int n;
void calcp() {
  mark[1] = 1;
  for (int i = 2; i < maxm; i++) {
    if (mark[i]) continue;
    primes.push_back(i);
    for (int c = 2 * i; c < maxm; c += i) mark[c] = 1;
  }
}
void primefact() {
  for (int i = 1; i < maxm; i++) {
    for (int j = 0; j < primes.size(); j++) {
      if (i % primes[j] == 0) {
        factors[i] |= (1 << j);
      }
    }
  }
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
}
int xor_delta(int a, int b) {
  int c = a - (a & b);
  return c;
}
int diffr(int a, int b) { return max(a - b, b - a); }
void calc() {
  for (int i = 0; i < n; i++) {
    for (int k = 1; k <= 60; k++) {
      int x = (~factors[k]) & ((1 << 17) - 1);
      for (int s = x;; s = (s - 1) & x) {
        if (i == 0 or dp[i - 1][s] + diffr(a[i], k) < dp[i][s | factors[k]]) {
          if (i) {
            dp[i][s | factors[k]] = dp[i - 1][s] + (diffr(a[i], k));
            b[i][factors[k] | s] = k;
          } else if (dp[i][s | factors[k]] > diffr(a[i], k)) {
            dp[i][s | factors[k]] = diffr(a[i], k);
            b[i][factors[k] | s] = k;
          }
        }
        if (!s) break;
      }
    }
  }
}
void answer() {
  int nmask = 0;
  int cmin = inf;
  for (int mask = 0; mask < (1 << 17); mask++)
    if (dp[n - 1][mask] < dp[n - 1][nmask]) nmask = mask;
  stack<int> ans;
  for (int i = n - 1; i > -1; i--) {
    ans.push(b[i][nmask]);
    nmask = nmask - factors[b[i][nmask]];
  }
  while (ans.size()) {
    cout << ans.top() << ' ';
    ans.pop();
  }
}
void print_binary(int a) {
  while (a) {
    cout << a % 2;
    a /= 2;
  }
}
void preset() {
  for (int i = 0; i < n; i++) fill(dp[i], dp[i] + lg, inf);
}
void test() {
  cout << diffr(7, 7);
  return;
  for (int i = 0; i < 60; i++) {
    cout << endl << i << ": ";
    print_binary(factors[i]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  calcp();
  primefact();
  input();
  preset();
  calc();
  answer();
}