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>
int in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
const int INF = int(1e9 + 7);
int n;
int v[110];
int masks[61];
int dp[(1 << 18)][110];
int sol[(1 << 18)][110];
string bin(int n) {
  string s;
  while (n > 0) {
    s += (char)(n % 2 + '0');
    n /= 2;
  }
  while (s.size() < 18) s += "0";
  reverse((s).begin(), (s).end());
  return s;
}
int f(int mask, int pos) {
  if (dp[mask][pos] != -1) return dp[mask][pos];
  if (pos == n) return 0;
  int res = INT_MAX;
  for (int i = 1; i <= 60; i++) {
    if ((masks[i] & mask) > 1) {
      continue;
    }
    int x = f(mask | masks[i], pos + 1) + abs(v[pos] - i);
    if (res > x) {
      res = x;
      sol[mask][pos] = i;
    }
  }
  return dp[mask][pos] = res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<int> factores;
  for (int i = 1; factores.size() < 18; i++) {
    bool primo = true;
    for (int j = 2; j < i; j++)
      if (i % j == 0) primo = false;
    if (primo) factores.push_back(i);
  }
  for (int i = 1; i <= 60; i++) {
    int mask = 0;
    for (int j = 0; j < factores.size(); j++) {
      if (i % factores[j] == 0) mask |= (1 << j);
    }
    masks[i] = mask;
  }
  memset(dp, (-1), sizeof(dp));
  f(0, 0);
  int mask = 0;
  for (int i = 0; i < n; i++) {
    cout << sol[mask][i] << " ";
    mask |= masks[sol[mask][i]];
  }
  return 0;
}