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 f[101][131111], pi[101][131111], pj[101][131111], mc[33][131111],
    jc[33][131111];
const int prime[16] = {2,  3,  5,  7,  11, 13, 17, 19,
                       23, 29, 31, 37, 41, 43, 47, 53};
int a[101];
int n;
void prework() {
  memset(mc, 50, sizeof mc);
  for (int i = 1; i <= 30; i++)
    for (int j = 1; j < 59; j++) {
      int t = 0;
      for (int k = 0; k < 16; k++)
        if (j % prime[k] == 0) t |= 1 << k;
      mc[i][t] = min(mc[i][t], abs(i - j));
      if (abs(i - j) == mc[i][t]) jc[i][t] = j;
    }
}
void dp() {
  memset(f, 50, sizeof f);
  f[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (1 << 16); j++) {
      for (int k = 16; k >= 0; k--) {
        if (!(j & (1 << k))) {
          if (f[i][j] + mc[a[i + 1]][1 << k] < f[i + 1][j | (1 << k)]) {
            f[i + 1][j | (1 << k)] = f[i][j] + mc[a[i + 1]][1 << k];
            pi[i + 1][j | (1 << k)] = i, pj[i + 1][j | (1 << k)] = j;
          }
          for (int r = 0; r < k; r++) {
            if (prime[k] * prime[r] > 60) break;
            if (!(j & (1 << r))) {
              if (f[i][j] + mc[a[i + 1]][(1 << r) + (1 << k)] <
                  f[i + 1][j | ((1 << r) + (1 << k))]) {
                f[i + 1][j | ((1 << r) + (1 << k))] =
                    f[i][j] + mc[a[i + 1]][(1 << r) + (1 << k)];
                pi[i + 1][j | ((1 << r) + (1 << k))] = i,
                                                pj[i + 1]
                                                  [j | ((1 << r) + (1 << k))] =
                                                      j;
              }
            }
          }
        }
      }
      if (!(j & 1) && !(j & 2) && !(j & 4)) {
        int t = 7;
        if (f[i][j] + mc[a[i + 1]][t] < f[i + 1][j | t]) {
          f[i + 1][j | t] = f[i][j] + mc[a[i + 1]][t];
          pi[i + 1][j | t] = i, pj[i + 1][j | t] = j;
        }
      }
      if (!(j & 1) && !(j & 2) && !(j & 8)) {
        int t = 11;
        if (f[i][j] + mc[a[i + 1]][t] < f[i + 1][j | t]) {
          f[i + 1][j | t] = f[i][j] + mc[a[i + 1]][t];
          pi[i + 1][j | t] = i, pj[i + 1][j | t] = j;
        }
      }
      if (f[i][j] + mc[a[i + 1]][0] < f[i + 1][j]) {
        f[i + 1][j] = f[i][j] + mc[a[i + 1]][0];
        pi[i + 1][j] = i, pj[i + 1][j] = j;
      }
    }
}
int b[101];
void print() {
  int t = 1 << 25, u = n, v;
  for (int j = 0; j < (1 << 16); j++)
    if (f[n][j] < t) t = f[n][j], v = j;
  for (; u;) {
    int i = pi[u][v], j = pj[u][v];
    if ((j ^ v) == 0)
      b[u] = 1;
    else {
      b[u] = jc[a[u]][v ^ j];
    }
    u = i, v = j;
  }
  printf("%d", b[1]);
  for (int i = 2; i <= n; i++) printf(" %d", b[i]);
  printf("\n");
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  prework();
  dp();
  print();
  return 0;
}