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 oo = 1e9 + 7;
int dp[111][1 << 18], tr[111][1 << 18], prime[111], lp, mark[111];
int getbit(int x, int pos) { return (x >> pos) & 1; }
int onbit(int x, int pos) { return (x + (1 << pos)); }
void init() {
  int nt[200];
  for (int i = (1), _b = (60); i <= _b; i++) nt[i] = 1;
  nt[1] = 0;
  for (int i = (2), _b = (10); i <= _b; i++) {
    if (nt[i] == 1) {
      int j = i;
      while (j < 60) {
        j += i;
        nt[j] = 0;
      }
    }
  }
  lp = -1;
  for (int i = (1), _b = (60); i <= _b; i++) {
    if (nt[i]) {
      lp++;
      prime[lp] = i;
    }
  }
  for (int i = (1), _b = (60); i <= _b; i++) mark[i] = 0;
  for (int i = (1), _b = (60); i <= _b; i++) {
    int t = 0;
    for (int j = (0), _b = (lp); j <= _b; j++) {
      if (i % prime[j] == 0) {
        t = onbit(t, j);
      }
    }
    mark[i] = t;
  }
}
int abS(int x) {
  if (x > 0) return x;
  return -x;
}
int main() {
  int n, a[111];
  cin >> n;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  init();
  int maxtt = (1 << 17) - 1;
  for (int i = (0), _b = (maxtt); i <= _b; i++) dp[0][i] = 0;
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int tt = (0), _b = (maxtt); tt <= _b; tt++) dp[i][tt] = oo;
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int val = (1), _b = (60); val <= _b; val++) {
      for (int tt = (0), _b = (maxtt); tt <= _b; tt++) {
        if ((mark[val] & tt) == 0) {
          int ttnew = tt + mark[val];
          int dpval = dp[i - 1][tt] + abS(val - a[i]);
          if (dpval < dp[i][ttnew]) {
            dp[i][ttnew] = dpval;
            tr[i][ttnew] = val;
          }
        }
      }
    }
  }
  int ret = 0;
  for (int tt = (0), _b = (maxtt); tt <= _b; tt++)
    if (dp[n][ret] > dp[n][tt]) ret = tt;
  int res[111];
  for (int i = (n), _b = (1); i >= _b; i--) {
    res[i] = tr[i][ret];
    ret -= mark[res[i]];
  }
  for (int i = (1), _b = (n); i <= _b; i++)
    printf("%d%c", res[i], i == n ? '\n' : ' ');
  return 0;
}