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 vector<int> PRIMES{2,  3,  5,  7,  11, 13, 17, 19, 23,
                         29, 31, 37, 41, 43, 47, 53, 59};
const pair<int, int> NA{-1, -1};
const int INF = INT_MAX / 2;
int n;
vector<int> a;
vector<vector<pair<int, int>>> cache;
int total = 0, total_hit = 0;
vector<vector<int>> prime_factors;
pair<int, int> dfs(int which, int prime_used) {
  if (which >= n) {
    return {0, -1};
  }
  total++;
  if (cache[which][prime_used] != NA) {
    total_hit++;
    return cache[which][prime_used];
  }
  pair<int, int> ans{INF, -1};
  int ub = a[which] + a[which] - 1;
  for (int b = 1; b < ub + 1; b++) {
    int new_prime_used = prime_used;
    bool good = true;
    for (auto i : prime_factors[b]) {
      if (((1 << i) & prime_used) > 0) {
        good = false;
        break;
      }
      new_prime_used += 1 << i;
    }
    if (!good) {
      continue;
    }
    int diff = abs(a[which] - b);
    auto ans1 = dfs(which + 1, new_prime_used);
    if (diff + ans1.first < ans.first) {
      ans.first = ans1.first + diff;
      ans.second = b;
    }
  }
  return cache[which][prime_used] = ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  {
    prime_factors = vector<vector<int>>(60);
    for (int i = 1; i < 60; i++) {
      for (int j = 0; j < PRIMES.size(); j++) {
        if (i < PRIMES[j]) {
          break;
        }
        if (i % PRIMES[j] == 0) {
          prime_factors[i].push_back(j);
        }
      }
    }
  }
  cache = vector<vector<pair<int, int>>>(
      n, vector<pair<int, int>>(1 << PRIMES.size(), NA));
  auto ans = dfs(0, 0);
  ;
  ;
  int which = 0, prime_used = 0;
  while (which < n) {
    int b = cache[which][prime_used].second;
    cout << b << ' ';
    if (b > 1) {
      for (int i = 0; i < PRIMES.size(); i++) {
        if (b % PRIMES[i] == 0) {
          prime_used += 1 << i;
        }
      }
    }
    which++;
  }
}