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 mod = 1000000007;
const int N = (1 << 16) + 3;
vector<int> g[N];
int a[N];
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
int n, h;
int dp[103][N];
int primes[17] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                  29, 31, 37, 41, 43, 47, 53, 59};
int sub[103];
void pre() {
  int i, j;
  sub[1] = 0;
  for (i = 2; 2 < 59 ? i < 59 : i > 59; 2 < 59 ? i += 1 : i -= 1) {
    sub[i] = 0;
    for (j = 0; 0 < 16 ? j < 16 : j > 16; 0 < 16 ? j += 1 : j -= 1) {
      if (i % primes[j] == 0) sub[i] |= (1 << j);
    }
  }
}
int b[103];
int go(int pos, int mask) {
  int &ans = dp[pos][mask];
  if (ans != -1) return ans;
  ans = 1e9;
  int i;
  if (pos == n) return 0;
  for (i = 1; 1 < 59 ? i < 59 : i > 59; 1 < 59 ? i += 1 : i -= 1) {
    int submask = sub[i];
    if ((submask & mask) == 0) {
      int nval = abs(a[pos] - i) + go(pos + 1, mask | submask);
      if (nval < ans) {
        b[pos] = i;
        ans = nval;
      }
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, k, j;
  pre();
  cin >> n;
  for (i = 0; i < n; i++)
    for (j = 0; j < N; j++) dp[i][j] = -1;
  for (i = 0; i < n; i++) cin >> a[i];
  int val = go(0, 0);
  int mask = 0, cur = 0;
  for (i = 0; i < n; i++)
    for (j = 1; 1 < 59 ? j < 59 : j > 59; 1 < 59 ? j += 1 : j -= 1) {
      if ((mask & sub[j]) != 0) continue;
      if (abs(a[i] - j) + cur + go(i + 1, mask ^ sub[j]) == val) {
        cout << j << " ";
        cur += abs(a[i] - j);
        mask ^= sub[j];
        break;
      }
    }
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
}
void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}