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;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int P[59];
int PP[59];
int C[59];
int A[101];
int D[101][1 << 16];
int fnd(int i, int d) {
  int &res = D[i][d];
  if (res >= 0) return res;
  if (i == n) return res = 0;
  int j;
  res = 1012345678;
  for (j = (1); j < (59); ++j)
    if (!(d & C[j])) minn(res, abs(j - A[i]) + fnd(i + 1, d | C[j]));
  return res;
}
void fnddfs(int i, int d) {
  const int &res = D[i][d];
  if (i == n) return;
  int j;
  for (j = (1); j < (59); ++j)
    if (!(d & C[j]) && res == abs(j - A[i]) + fnd(i + 1, d | C[j])) {
      printf((firstout) ? "%"
                          "d"
                        : " %"
                          "d",
             (j)),
          firstout = 0;
      fnddfs(i + 1, d | C[j]);
      return;
    }
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  P[0] = P[1] = 0;
  for (i = (2); i < (59); ++i) P[i] = 1;
  for (i = 2; i * i < 59; ++i)
    if (P[i])
      for (j = i * i; j < 59; j += i) P[j] = 0;
  n = 0;
  for (i = (2); i < (59); ++i)
    if (P[i]) P[n++] = i;
  for (i = (0); i < (n); ++i) PP[P[i]] = i;
  C[0] = C[1] = 0;
  for (i = (2); i < (59); ++i) {
    a = i;
    d = 0;
    for (j = 2; j * j <= a; ++j)
      if (a % j == 0) {
        d |= 1 << PP[j];
        for (; a % j == 0;) a /= j;
      }
    if (a > 1) d |= 1 << PP[a];
    C[i] = d;
  }
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    for (i = (0); i < (n); ++i)
      scanf(
          "%"
          "d",
          &(A[i]));
    for (i = (0); i < (n + 1); ++i)
      for (j = (0); j < (1 << 16); ++j) D[i][j] = -1;
    fnd(0, 0);
    fnddfs(0, 0);
    printf("\n"), firstout = 1;
  }
  return 0;
}