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 n;
pair<int, int> v[101];
int dp[101][101][121][1 << 4];
vector<int> primes;
int vis[2001];
pair<int, int> path[101][101][121][1 << 4];
int answ[101];
int setBit(int mask, int curr) { return mask | (1 << curr); }
int getBit(int mask, int curr) { return (mask >> curr) & 1; }
int solve(int curr, int val, int pr, int mask) {
  if (curr == n) return 0;
  if (pr == primes.size()) return 0x3f3f3f3f;
  if (val > 100) return 0x3f3f3f3f;
  int& ret = dp[curr][val][pr][mask];
  if (ret != -1) return ret;
  ret = 0x3f3f3f3f;
  pair<int, int>& p = path[curr][val][pr][mask];
  for (int i = 0; i < 4; ++i) {
    if (!getBit(mask, i)) {
      for (int j = 1; j <= 5; ++j) {
        int retorno =
            solve(curr, val * pow((double)primes[i], j), pr, setBit(mask, i));
        if (retorno < ret) {
          p = make_pair(i, j);
          ret = retorno;
        }
      }
    }
  }
  int retorno = solve(curr + 1, 1, pr, mask) + abs(v[curr].first - val);
  if (retorno < ret) {
    p = make_pair(4, -1);
    ret = retorno;
  }
  for (int i = pr; i < primes.size(); ++i) {
    retorno =
        solve(curr + 1, 1, i + 1, mask) + abs(v[curr].first - val * primes[i]);
    if (retorno < ret) {
      p = make_pair(i + 1, -1);
      ret = retorno;
    }
  }
  return ret;
}
void sieve(int size) {
  for (int i = 2; i <= size; ++i) {
    if (vis[i]) continue;
    primes.push_back(i);
    if (primes.size() == 200) return;
    for (int j = i; j <= size; j += i) {
      vis[j] = 1;
    }
  }
}
void print(int curr, int val, int pr, int mask) {
  if (curr == n) return;
  pair<int, int> ret = path[curr][val][pr][mask];
  int i = ret.first;
  int j = ret.second;
  if (i >= 0 && i < 4) {
    return print(curr, val * pow((double)primes[i], j), pr, setBit(mask, i));
  } else if (i == 4) {
    answ[v[curr].second] = val;
    return print(curr + 1, 1, pr, mask);
  } else {
    answ[v[curr].second] = val * primes[i - 1];
    return print(curr + 1, 1, i, mask);
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &v[i].first);
    v[i].second = i;
  }
  sieve(120);
  sort(v, v + n);
  memset(dp, -1, sizeof dp);
  int retorno = solve(0, 1, 4, 0);
  print(0, 1, 4, 0);
  for (int i = 0; i < n; ++i) {
    printf("%d", answ[i]);
    if (i == n - 1)
      printf("\n");
    else
      printf(" ");
  }
  return 0;
}