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>
const int B = 65;
const int N = 110;
const int BITS = 17;
const int UNIVERSE = (1 << BITS) - 1;
const int primes[BITS] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                          29, 31, 37, 41, 43, 47, 53, 59};
using namespace std;
int n;
int a[N];
int prime[B];
int dp[(1 << BITS) + 10][N];
void build_optimal_solution(int mask_req, int idx) {
  if (idx == 0) {
    int sol = -1;
    for (int b = 1; b < a[0] + a[0]; b++) {
      int mask = prime[b];
      if (mask == mask_req) {
        if (sol == -1 || abs(a[0] - b) < abs(a[0] - sol)) sol = b;
      }
    }
    cout << sol << ' ';
    return;
  }
  for (int b = 1; b < a[idx] + a[idx]; b++) {
    int mask = prime[b];
    if (mask & (~mask_req)) continue;
    if (dp[mask_req][idx] == abs(a[idx] - b) + dp[mask_req ^ mask][idx - 1]) {
      build_optimal_solution(mask_req ^ mask, idx - 1);
      cout << b << ' ';
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int mask = 0; mask < (1 << BITS); mask++)
    for (int idx = 0; idx < N; idx++) dp[mask][idx] = 1e9;
  for (int i = 1; i <= 60; i++) {
    for (int j = 0; j < BITS; j++) {
      if (i % primes[j] == 0) prime[i] |= (1 << j);
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int b = 1; b < a[0] + a[0]; b++) {
    int mask = prime[b];
    dp[mask][0] = min(dp[mask][0], abs(a[0] - b));
  }
  for (int idx = 1; idx < n; idx++) {
    for (int b = 1; b < a[idx] + a[idx]; b++) {
      int mask = prime[b];
      int from_mask = UNIVERSE ^ mask;
      for (int submask = from_mask;; submask = (submask - 1) & from_mask) {
        dp[submask | mask][idx] = min(dp[submask | mask][idx],
                                      abs(a[idx] - b) + dp[submask][idx - 1]);
        if (submask == 0) break;
      }
    }
  }
  int mask_req = 0;
  for (int mask = 0; mask < (1 << BITS); mask++)
    if (dp[mask][n - 1] < dp[mask_req][n - 1]) mask_req = mask;
  build_optimal_solution(mask_req, n - 1);
  cout << '\n';
  return 0;
}