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;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool EQ2(double a, double b) { return fabs(a - b) < 1e-7; }
int n, seive[61], prime[61], store[60], c;
int a[110];
int dp[110][(1 << 17) + 10];
pair<int, int> nxt[110][(1 << 17) + 10];
int ans[110][(1 << 17) + 10];
void seiveGen() {
  int sqrtn = sqrt(61);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (!seive[i >> 1]) {
      for (int j = i * i; j < 61; j += i + i) {
        seive[j >> 1] = 1;
      }
    }
  }
  prime[c++] = 2;
  for (int i = 3; i < 61; i += 2) {
    if (!seive[i >> 1]) prime[c++] = i;
  };
  prime[c++] = 100000000;
}
void init() {
  for (int i = 1; i < 61; i++) {
    for (int j = 0; prime[j] <= i; ++j) {
      if (i % prime[j] == 0) {
        store[i] = setBit(store[i], j);
      }
    };
  }
}
int recur(int index, int mask) {
  if (index == n) return 0;
  int &ret = dp[index][mask];
  if (ret != -1) return ret;
  ret = 100000000;
  for (int i = 1; i < 61; ++i) {
    if (store[i] & mask) continue;
    int temp = recur(index + 1, mask | store[i]);
    if (temp + abs(i - a[index]) < ret) {
      nxt[index][mask] = pair<int, int>(index + 1, mask | store[i]);
      ret = temp + abs(i - a[index]);
      ans[index][mask] = i;
    }
  }
  return ret;
}
void ansGen() {
  recur(0, 0);
  pair<int, int> cur(0, 0);
  ;
  for (int i = 0; i < n; ++i) {
    cout << ans[cur.first][cur.second] << " ";
    cur = nxt[cur.first][cur.second];
  }
}
int main() {
  seiveGen();
  init();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  memset(dp, -1, sizeof(dp));
  ansGen();
  return 0;
}