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;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
struct node {
  int pos;
  int x;
  int y;
} a[101];
int ans[1 << 17][60];
int dp[20][1 << 17];
int v[40];
int vis[100];
int cnt = 0;
int n = 16;
bool cmp(node a, node b) { return a.x > b.x; }
void init() {
  for (int i = 0; i < (1 << 16); i++) {
    for (int j = 1; j <= 59; j++) {
      int t = i;
      int flag = 1;
      for (int k = 0; k < cnt; k++) {
        if ((i & (1 << k)) && j % v[k] == 0) {
          ans[i][j] = -1;
          flag = 0;
          break;
        } else if (j % v[k] == 0) {
          t |= (1 << k);
        }
      }
      if (flag) {
        ans[i][j] = t;
      }
    }
  }
}
void dfs(int l, int x, int nmin) {
  if (l == 0) return;
  int res = 1;
  for (int i = 0; i < (1 << 16); i++) {
    for (int j = 1; j <= 59; j++) {
      if (ans[i][j] == x && dp[l - 1][i] + fabs(j - a[l].x) == nmin) {
        dfs(l - 1, i, dp[l - 1][i]);
        res = j;
        goto end;
      }
    }
  }
end:
  a[l].y = res;
  return;
}
int main() {
  for (int i = 2; i <= 58; i++) {
    if (!vis[i]) {
      v[cnt++] = i;
      for (int j = i * 2; j <= 58; j += i) {
        vis[j] = 1;
      }
    }
  }
  init();
  int N;
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i].x);
    a[i].pos = i, a[i].y = 1;
  }
  sort(a + 1, a + 1 + N, cmp);
  n = min(n, N);
  memset(dp, inf, sizeof dp);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << 16); j++) {
      if (dp[i - 1][j] != inf) {
        for (int k = 1; k <= 59; k++) {
          if (ans[j][k] != -1) {
            dp[i][ans[j][k]] =
                min(dp[i][ans[j][k]], dp[i - 1][j] + (int)fabs(k - a[i].x));
          }
        }
      }
    }
  }
  int ans = inf;
  int x;
  for (int j = 0; j < (1 << 16); j++) {
    if (ans > dp[n][j]) {
      ans = dp[n][j];
      x = j;
    }
  }
  dfs(n, x, ans);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (i == a[j].pos) {
        printf("%d ", a[j].y);
      }
    }
  }
  return 0;
}