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;
int num[100 + 10];
int memo[100 + 10][1 << 18];
int visit[100 + 10][1 << 18];
vector<int> fact[60];
int prime[17] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                 29, 31, 37, 39, 41, 43, 47, 53};
map<int, int> ind;
int REC(int p, int mask) {
  if (p == n) return 0;
  if (~memo[p][mask]) return memo[p][mask];
  int res = 1000000000, a = 1000000000, b = 1000000000, tmp, g;
  a = REC(p + 1, mask | 1) + abs(num[p] - 1);
  for (int i = 2; i < 59; i++) {
    bool flag = 1;
    int newmask = 0;
    for (int j = 0; j < (int)fact[i].size(); j++) {
      int z = ind[fact[i][j]];
      if (mask & (1 << z)) {
        flag = 0;
        break;
      } else
        newmask |= (1 << z);
    }
    if (flag) {
      tmp = REC(p + 1, mask | newmask) + abs(num[p] - i);
      if (tmp < b) {
        b = tmp;
        g = i;
      }
    }
  }
  if (a <= b) {
    res = a;
    visit[p][mask] = 1;
  } else {
    res = b;
    visit[p][mask] = g;
  }
  return memo[p][mask] = res;
}
void factor(int x) {
  int f = 2, xx = x;
  while (f * f <= x) {
    bool flag = 0;
    while (x % f == 0) x /= f, flag = 1;
    if (flag) fact[xx].push_back(f);
    f++;
  }
  if (x > 1) fact[xx].push_back(x);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> num[i];
  memset((memo), (-1), sizeof(memo));
  for (int i = 2; i < 59; i++) {
    factor(i);
  }
  for (int i = 0; i < 17; i++) {
    ind[prime[i]] = i + 1;
  }
  REC(0, 0);
  vector<int> ans;
  int p = 0, mask = 0;
  while (p < n) {
    int nxt = visit[p][mask];
    ans.push_back(nxt);
    if (nxt == 1)
      mask |= 1;
    else {
      for (int i = 0; i < (int)fact[nxt].size(); i++) {
        int z = ind[fact[nxt][i]];
        mask |= (1 << z);
      }
    }
    p++;
  }
  for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}