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 int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const long long INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);
template <class T>
T take(queue<T> &O) {
  T tmp = O.front();
  O.pop();
  return tmp;
}
template <class T>
T take(stack<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
template <class T>
T take(priority_queue<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
template <class T>
inline void getint(T &num) {
  bool neg = 0;
  num = 0;
  char c;
  while ((c = getchar_unlocked()) && (!isdigit(c) && c != '-'))
    ;
  if (c == '-') {
    neg = 1;
    c = getchar_unlocked();
  }
  do num = num * 10 + c - '0';
  while ((c = getchar_unlocked()) && isdigit(c));
  num *= (neg) ? -1 : 1;
}
void OPEN(string in = "input.txt", string out = "output.txt") {
  freopen(in.c_str(), "r", stdin);
  freopen(out.c_str(), "w", stdout);
  return;
}
int dp[101][1 << 10][8 + 1];
int pr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int ext[] = {31, 37, 41, 43, 47, 53, 59, 61};
int n;
pair<int, int> arr[101];
int nmask[61];
int f(int pos, int mask, int as) {
  int &ret = dp[pos][mask][as];
  if (ret != -1) return ret;
  if (pos == n) return ret = 0;
  ret = INF / 2;
  ret = min(ret, f(pos + 1, mask, as) + arr[pos].first - 1);
  for (int l = arr[pos].first, r = arr[pos].first, cnt = 0;
       cnt <= 30 && mask != (1 << 17) - 1; ++cnt, --l, ++r) {
    if (l > 1 && nmask[l] && (mask & (nmask[l])) == 0)
      ret = min(ret, f(pos + 1, mask | nmask[l], as) + cnt);
    if (r < 2 * arr[pos].first && nmask[r] && (mask & (nmask[r])) == 0)
      ret = min(ret, f(pos + 1, mask | nmask[r], as) + cnt);
  }
  if (as < 8)
    ret = min(ret, f(pos + 1, mask, as + 1) + ext[as] - arr[pos].first);
  return ret;
}
vector<int> ans;
void bt(int pos, int mask, int as) {
  int &ret = dp[pos][mask][as];
  if (pos == n) return;
  if (f(pos + 1, mask, as) + arr[pos].first - 1 == ret) {
    ans.push_back(1);
    bt(pos + 1, mask, as);
    return;
  }
  for (int l = arr[pos].first, r = arr[pos].first, cnt = 0; cnt <= 30;
       ++cnt, --l, ++r) {
    if (l > 1 && (mask & (nmask[l])) == 0 && nmask[l] &&
        f(pos + 1, mask | nmask[l], as) + cnt == ret) {
      ans.push_back(l);
      bt(pos + 1, mask | nmask[l], as);
      return;
    }
    if (r <= 2 * arr[pos].first && nmask[r] && (mask & (nmask[r])) == 0 &&
        f(pos + 1, mask | nmask[r], as) + cnt == ret) {
      ans.push_back(r);
      bt(pos + 1, mask | nmask[r], as);
      return;
    }
  }
  if (as < 8) {
    ans.push_back(ext[as]);
    bt(pos + 1, mask, as + 1);
    return;
  }
}
int main() {
  for (int(i) = (0), _t = (10); i < (_t); ++(i)) {
    for (int c = pr[i]; c <= 60; c += pr[i]) nmask[c] |= 1 << i;
  }
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int(i) = (0), _t = (n); i < (_t); ++(i)) {
    cin >> arr[i].first;
    arr[i].second = i;
  }
  sort(arr, arr + (n));
  f(0, 0, 0);
  bt(0, 0, 0);
  for (int(i) = (0), _t = (n); i < (_t); ++(i))
    for (int(j) = (i), _t = (n); j < (_t); ++(j))
      if (arr[j].second == i) {
        swap(ans[i], ans[j]);
        swap(arr[j], arr[i]);
      }
  for (int(i) = (0), _t = ((int)ans.size()); i < (_t); ++(i))
    cout << ans[i] << (i == (int)ans.size() - 1 ? "\n" : " ");
  return 0;
}