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[111][1 << 16], p[16], a[233], miao[69], ans[111][1 << 16],
    pre[111][1 << 16];
vector<int> calc(int x) {
  vector<int> ret;
  for (int i = 2; i <= x; i++) {
    if (x % i == 0) ret.push_back(i);
    while (x % i == 0) x /= i;
  }
  return ret;
}
vector<int> v[69];
void output(int n, int k) {
  if (n > 1) output(n - 1, pre[n][k]);
  cout << ans[n][k] << ' ';
}
int main() {
  int n;
  ios::sync_with_stdio(false);
  cin >> n;
  memset(miao, 0, sizeof(miao));
  int cnt = 0;
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 2; i <= 58; i++) {
    v[i] = calc(i);
    if (v[i][0] == i) p[i] = cnt++;
    for (int k = 0; k < v[i].size(); k++) miao[i] |= (1 << p[v[i][k]]);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  miao[1] = 0;
  for (int i = 0; i < n; i++)
    for (int k = 0; k < (1 << 16); k++)
      if (f[i][k] != 0x3f3f3f3f)
        for (int j = 1; j <= 58; j++)
          if (!(k & miao[j])) {
            int l = (k | miao[j]);
            if (f[i + 1][l] > f[i][k] + abs(j - a[i + 1]))
              f[i + 1][l] = f[i][k] + abs(j - a[i + 1]), ans[i + 1][l] = j,
                    pre[i + 1][l] = k;
          }
  int minn = 0x3f3f3f3f, pos = 0;
  for (int i = 0; i < (1 << 16); i++)
    if (minn > f[n][i]) minn = f[n][i], pos = i;
  output(n, pos);
  cout << '\n';
  return 0;
}