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 primes[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
pair<int, int> dp[100][1 << 16];
bool mem[100][1 << 16];
int dist[100];
int t[100];
int z, n;
int distrib(int p) {
  int mask = 0;
  for (int i = 0; i < 16; i++) {
    if (p % primes[i] == 0) mask |= (1 << i);
  }
  return mask;
}
pair<int, int> f(int n, int mask) {
  if (mem[n][mask]) return dp[n][mask];
  if (!n) return make_pair(1000000001, 0);
  mem[n][mask] = true;
  pair<int, int> ret = make_pair(1000000001, 0);
  int maxn = min(58, 2 * t[n]);
  for (int i = 1; i <= maxn; i++) {
    if ((mask | dist[i]) != mask) continue;
    int nmask = mask ^ dist[i];
    pair<int, int> tmp = make_pair(f(n - 1, nmask).first + abs(i - t[n]), i);
    if (ret.first > tmp.first) ret = tmp;
  }
  return dp[n][mask] = ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &t[i]);
  for (int i = 1; i <= 60; i++) dist[i] = distrib(i);
  for (int i = 1; i <= 60; i++) dp[0][dist[i]] = make_pair(1000000001, 0);
  for (int i = 1; i <= 60; i++) {
    if (abs(i - t[0]) < dp[0][dist[i]].first)
      dp[0][dist[i]] = make_pair(abs(i - t[0]), i);
    mem[0][dist[i]] = true;
  }
  pair<int, int> mn = make_pair(1000000001, 0);
  int cmask;
  for (int i = 0; i < 1 << 16; i++) {
    if (mn.first > f(n - 1, i).first) {
      mn = f(n - 1, i);
      cmask = i;
    }
  }
  int i = n;
  vector<int> r;
  while (--i >= 0) {
    mn.second = f(i, cmask).second;
    r.push_back(mn.second);
    cmask ^= dist[mn.second];
  }
  reverse(r.begin(), r.end());
  for (int i = 0; i < n; i++) {
    printf("%d ", r[i]);
  }
  printf("\n");
  return 0;
}