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 inf = 1e9;
int n, a[100];
int memo[101][1 << 16], memo_b[101][1 << 16], memo_f[60];
const int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int factorize(int x) {
  if (memo_f[x] != -1) return memo_f[x];
  int r = 0;
  for (int i = 0; i < int(16); i++) {
    if (x % p[i] == 0) {
      r |= 1 << i;
    }
  }
  return memo_f[x] = r;
}
int rec(int c, int set) {
  if (c == 0) return 0;
  if (memo[c][set] != -1) return memo[c][set];
  int mi = inf;
  for (int i = 1; i <= 2 * a[c - 1] - 1; i++) {
    int f = factorize(i);
    if ((set & f) == f) {
      int k = rec(c - 1, set ^ f) + abs(a[c - 1] - i);
      if (mi > k) {
        mi = k;
        memo_b[c][set] = i;
      }
    }
  }
  return memo[c][set] = mi;
}
int main() {
  memset(memo, -1, sizeof(memo));
  memset(memo_b, -1, sizeof(memo_b));
  memset(memo_f, -1, sizeof(memo_f));
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  rec(n, (1 << 16) - 1);
  int b[100] = {};
  int set = (1 << 16) - 1;
  for (int i = n; i > 0; i--) set -= factorize(b[i - 1] = memo_b[i][set]);
  for (int i = 0; i < int(n); i++) cout << b[i] << " ";
  cout << endl;
}