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 dp[105][1 << 18];
int prime[65];
int arr[105];
int pos[60];
int n;
int factors[60];
void sieve() {
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= 60; i++)
    if (prime[i])
      for (int j = 2; j * i <= 60; j++) prime[i * j] = 0;
}
int solve(int idx, int mask) {
  if (idx == n) return 0;
  if (dp[idx][mask] != 1e9) return dp[idx][mask];
  for (int i = 1; i < 60; i++) {
    bool f = true;
    int mask2 = factors[i];
    if ((mask2 & mask) == 0)
      dp[idx][mask] =
          min(dp[idx][mask], solve(idx + 1, mask | mask2) + abs(arr[idx] - i));
  }
  return dp[idx][mask];
}
void printAns(int idx, int mask) {
  if (idx == n) return;
  for (int i = 1; i < 60; i++) {
    int mask2 = factors[i];
    if ((mask2 & mask) == 0) {
      int choice1 = solve(idx + 1, mask | mask2) + abs(arr[idx] - i);
      int optimal = solve(idx, mask);
      if (choice1 == optimal) {
        printf("%d ", i);
        printAns(idx + 1, mask | mask2);
        break;
      }
    }
  }
  return;
}
int main() {
  for (int i = 1; i <= 60; i++) prime[i] = 1;
  sieve();
  int cnt = 1;
  for (int i = 1; i < 60; i++)
    if (prime[i]) pos[i] = cnt++;
  for (int i = 2; i < 60; i++)
    for (int j = 2; j <= i; j++)
      if (i % j == 0 && prime[j]) factors[i] |= (1 << pos[j]);
  for (int i = 0; i < 105; i++)
    for (int j = 0; j < (1 << 18); j++) dp[i][j] = 1e9;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int a = solve(0, 0);
  printAns(0, 0);
}