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 sumpr;
const int maxn = 61;
int pr[30];
bool flag[maxn];
vector<int> p;
void get_prime() {
  for (int i = 2; i <= maxn; i++) {
    if (!flag[i]) pr[sumpr++] = i;
    for (int j = 0; j < sumpr && i * pr[j] <= maxn; j++) {
      flag[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
}
int state[66];
void pre_do() {
  for (int i = 2; i <= 59; i++) {
    int x = i;
    for (int j = 0; pr[j] <= x; j++) {
      int y = pr[j];
      if (x % y == 0) {
        while (x % y == 0) x = x / y;
        state[i] = (state[i] | (1 << j));
      }
    }
  }
}
int n;
int a[111];
int dp[111][1 << 18];
int pre[111][1 << 18];
void fuck(int sta, int nn) {
  if (nn == 0) return;
  int x = pre[nn][sta];
  p.push_back(x);
  if (x == 1)
    fuck(sta, nn - 1);
  else
    fuck((sta & (~(state[x]))), nn - 1);
}
int main() {
  get_prime();
  pre_do();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << 17) - 1; j++) {
      dp[i][j] = dp[i - 1][j] + abs(a[i] - 1);
      pre[i][j] = 1;
      for (int k = 2; k <= 59; k++) {
        int y = j;
        int x = state[k];
        if ((y | x) == y) {
          y = (y & (~x));
          if (dp[i][j] > dp[i - 1][y] + abs(a[i] - k)) {
            pre[i][j] = k;
            dp[i][j] = dp[i - 1][y] + abs(a[i] - k);
          }
        }
      }
    }
  }
  int ans = 1e9 + 9;
  int sta;
  for (int i = 0; i < (1 << 17) - 1; i++)
    if (ans > dp[n][i]) {
      ans = dp[n][i];
      sta = i;
    }
  fuck(sta, n);
  for (int i = n - 1; i >= 0; i--) printf("%d ", p[i]);
  return 0;
}