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 read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int Size = 101;
const int INF = 0x3fffffff;
const int prime[] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                     29, 31, 37, 41, 43, 47, 53, 59, 61};
int n, a[Size], b[Size], d[Size];
int dp[Size][200001];
int ans[Size][200001];
void getdiv(int x) {
  int k = 0, fakeYumaAK = x;
  for (int i = 0; i <= 16; i++) {
    while (x % prime[i] == 0) {
      x /= prime[i];
      k = k | (1 << i);
    }
  }
  d[fakeYumaAK] = k;
}
void init() {
  for (int i = 1; i < Size; i++) getdiv(i);
  memset(ans, -1, sizeof(ans));
  ans[0][0] = 0;
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
}
void dfs(int deep, int now) {
  if (!deep) return;
  dfs(deep - 1, now ^ d[ans[deep][now]]);
  printf("%d ", ans[deep][now]);
}
int main() {
  init();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 65536; j++) {
      if (ans[i][j] != -1) {
        for (int k = 1; k < 60; k++) {
          if (j & d[k]) continue;
          int tt = j | d[k], pp = dp[i][j] + abs(k - a[i + 1]);
          if (ans[i + 1][tt] == -1 || pp < dp[i + 1][tt]) {
            ans[i + 1][tt] = k;
            dp[i + 1][tt] = pp;
          }
        }
      }
    }
  }
  int ppp = INF, last = 0;
  for (int i = 0; i < 65536; i++) {
    if (ans[n][i] != -1 && dp[n][i] < ppp) {
      ppp = dp[n][i];
      last = i;
    }
  }
  dfs(n, last);
  return 0;
}