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;
using namespace std;
int pre[50];
int dp[101][1 << 17];
int fa[101][1 << 17];
int a[105];
int son[60];
int q[100], top;
int main() {
  int cnt = 0;
  memset(dp, -1, sizeof(dp));
  memset(son, 0, sizeof(0));
  for (int i = 2; i < 60; i++) {
    int t = sqrt(i), j;
    for (j = 2; j <= t; j++) {
      if (i % j == 0) break;
    }
    if (j == t + 1) pre[cnt++] = i;
  }
  for (int i = 2; i < 60; i++) {
    for (int j = 0; j < cnt; j++) {
      if (i % pre[j] == 0) son[i] |= (1 << j);
    }
  }
  int n, t = 1 << cnt;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t; j++) {
      if (dp[i][j] == -1) continue;
      for (int k = 1; k < 60; k++) {
        if (son[k] & j) continue;
        int tmp = son[k] | j;
        int num = dp[i][j] + abs(a[i + 1] - k);
        if (dp[i + 1][tmp] == -1 || dp[i + 1][tmp] > num) {
          dp[i + 1][tmp] = num;
          fa[i + 1][tmp] = k;
        }
      }
    }
  }
  int ans = 2000000009, ansid = 0;
  for (int i = 0; i < t; i++) {
    if (dp[n][i] < ans && dp[n][i] != -1) {
      ans = dp[n][i];
      ansid = i;
    }
  }
  top = 0;
  for (int i = n; i > 0; i--) {
    q[top++] = fa[i][ansid];
    ansid = ansid ^ son[q[top - 1]];
  }
  for (int i = top - 1; i >= 0; i--) {
    printf("%d%c", q[i], i == 0 ? '\n' : ' ');
  }
  return 0;
}