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;
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
const int N = 100 + 10;
int n, i, j, k, tot, a[N], info[N], dp[N][1 << 17], pre[N][1 << 17],
    num[N][1 << 17];
int primes[N];
void init() {
  for (i = 2; i <= 60; i++) {
    if (!primes[i]) primes[++primes[0]] = i;
    for (j = 1; j <= primes[0] && i * primes[j] <= 60; j++) {
      primes[i * primes[j]] = 1;
      if (i % primes[j] == 0) break;
    }
  }
  for (i = 1; i <= 60; i++) {
    for (j = 1; j <= primes[0]; j++) {
      if (i % primes[j] == 0) info[i] |= 1 << (j - 1);
    }
  }
}
void print(int idx, int status) {
  if (idx == 0) return;
  print(idx - 1, pre[idx][status]);
  printf("%d%c", num[idx][status], idx == n ? '\n' : ' ');
}
int main() {
  init();
  read(n);
  for (i = 1; i <= n; i++) {
    read(a[i]);
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (tot = 1 << primes[0], i = 0; i < n; i++) {
    for (j = 0; j < tot; j++) {
      for (k = 1; k <= 60; k++) {
        if (((~j) & info[k]) != info[k]) continue;
        if (dp[i][j] + abs(k - a[i + 1]) < dp[i + 1][j | info[k]]) {
          dp[i + 1][j | info[k]] = dp[i][j] + abs(k - a[i + 1]);
          pre[i + 1][j | info[k]] = j;
          num[i + 1][j | info[k]] = k;
        }
      }
    }
  }
  int res = 1 << 30;
  for (i = 0; i < tot; i++) res = min(res, dp[n][i]);
  for (i = 0; i < tot; i++) {
    if (dp[n][i] == res) {
      print(n, i);
      break;
    }
  }
  return 0;
}