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 N = 2e3 + 5;
int ms[65], dp[(1 << 17)][105], prime[20], a[105], b[105], c[65];
pair<int, int> p[(1 << 17)][105];
bool vis[65];
void ini() {
  int x = 0;
  for (int i = 2; i <= 60; i++)
    if (!vis[i]) {
      prime[x] = i;
      ms[i] = x++;
      for (int j = i + i; j <= 60; j += i) vis[j] = 1;
    }
}
int solve(int t) {
  if (t == 1) return 0;
  int S = 0;
  for (int i = 0; i < 17; i++) {
    int x = prime[i];
    if (t % x == 0) {
      S = S | (1 << ms[x]);
      while (t % x == 0) t /= x;
    }
  }
  return S;
}
void print(int S, int n) {
  if (!n) return;
  print(p[S][n].first, n - 1);
  printf("%d ", p[S][n].second);
}
int main() {
  ini();
  memset(dp, -1, sizeof(dp));
  int n, tot = (1 << 17);
  scanf("%d", &n);
  for (int S = 0; S < tot; S++) dp[S][0] = 0;
  for (int i = 1; i <= 60; i++) c[i] = solve(i);
  queue<int> Q[2];
  int now = 0;
  Q[now].push(0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    while (!Q[now].empty()) {
      int S = Q[now].front();
      Q[now].pop();
      for (int j = 1; j <= 60; j++) {
        int x = c[j];
        if ((x & S) == 0) {
          int &t = dp[(S | x)][i];
          if (t == -1) {
            t = dp[S][i - 1] + abs(j - a[i]);
            p[(S | x)][i] = {S, j};
            Q[now ^ 1].push(S | x);
          } else if (t > dp[S][i - 1] + abs(j - a[i])) {
            t = dp[S][i - 1] + abs(j - a[i]);
            p[S | x][i] = {S, j};
          }
        }
      }
    }
    now = now ^ 1;
  }
  int ans = -1;
  for (int S = 0; S < tot; S++)
    if (~dp[S][n]) {
      if (ans == -1)
        ans = S;
      else if (dp[S][n] < dp[ans][n])
        ans = S;
    }
  print(ans, n);
  return 0;
}