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;
struct point {
  int num, id;
};
int n, b[101], temp[101], ans, mid, vis[60], cnt, ccnt;
bool g[60][60];
point a[101];
bool cmp(point x, point y) { return x.num < y.num; }
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
void doit(int deep) {
  for (int i = deep + 1; i <= 58; i++)
    if (g[deep][i] && !vis[i]) vis[i] = deep;
}
void clear(int deep) {
  for (int i = deep; i <= 58; i++)
    if (vis[i] == deep) vis[i] = 0;
}
void calc() {
  for (int i = n - cnt; i >= 1; i--) temp[i] = 1;
  int flag = 1;
  for (int i = n - cnt + 1; i <= n; i++) {
    while (flag < 58) {
      flag++;
      if (vis[flag] == flag) {
        temp[i] = flag;
        break;
      }
    }
  }
  mid = 0;
  for (int i = 1; i <= n; i++) mid += (abs(a[i].num - temp[i]));
  if (mid < ans) {
    ans = mid;
    for (int i = 1; i <= n; i++) b[i] = temp[i];
    ccnt = cnt;
  }
}
void dfs(int deep) {
  if (cnt == n) {
    calc();
    return;
  }
  if (deep == 59) {
    calc();
    return;
  }
  dfs(deep + 1);
  if (!vis[deep]) {
    vis[deep] = deep;
    cnt++;
    doit(deep);
    dfs(deep + 1);
    cnt--;
    clear(deep);
  }
}
int main() {
  for (int i = 1; i <= 60; i++)
    for (int j = i + 1; j <= 60; j++)
      if (gcd(i, j) > 1)
        g[i][j] = 1;
      else
        g[i][j] = 0;
  ans = 0;
  memset(vis, 0, sizeof(vis));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].num;
    b[i] = 1;
    a[i].id = i;
    ans += a[i].num - b[i];
  }
  sort(a + 1, a + n + 1, cmp);
  cnt = 0;
  dfs(2);
  for (int i = 1; i <= n; i++) temp[a[i].id] = b[i];
  for (int i = 1; i <= n; i++) cout << temp[i] << " ";
  cout << endl;
  return 0;
}