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;
pair<int, int> add_pair(pair<int, int> a, pair<int, int> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
int power(int a, int b) {
  int res = 1;
  a = a % 998244353;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 998244353;
      b--;
    }
    a = (a * a) % 998244353;
    b >>= 1;
  }
  return res;
}
int fermat_inv(int y) { return power(y, 998244353 - 2); }
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int arr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int F[60];
const int N = 1 << 17;
void pre() {
  int i, j, mask;
  for (i = (1); i < (60); i += (1)) {
    mask = 0;
    for (j = (0); j < (17); j += (1)) {
      if (i % arr[j] == 0) {
        mask = mask | (1 << j);
      }
    }
    F[i] = mask;
  }
}
void solve() {
  int n, i, mask, submask, j, mn, val;
  cin >> n;
  int a[n];
  for (i = (0); i < (n); i += (1)) cin >> a[i];
  int dp[n][N];
  int ans[n][N];
  for (i = (0); i < (n); i += (1))
    for (j = (0); j < (N); j += (1)) dp[i][j] = (int)1e9;
  for (i = (1); i < (60); i += (1)) {
    if (dp[0][F[i]] > (int)abs(a[0] - i)) {
      dp[0][F[i]] = (int)abs(a[0] - i);
      ans[0][F[i]] = i;
    }
  }
  for (i = (1); i < (n); i += (1)) {
    for (j = (1); j < (60); j += (1)) {
      for (submask = (0); submask < (N); submask += (1)) {
        if (submask & F[j]) continue;
        if (dp[i][submask | F[j]] > dp[i - 1][submask] + (int)abs(a[i] - j)) {
          dp[i][submask | F[j]] = dp[i - 1][submask] + (int)abs(a[i] - j);
          ans[i][submask | F[j]] = j;
        }
      }
    }
  }
  mn = (int)1e9;
  for (i = (0); i < (N); i += (1)) {
    if (dp[n - 1][i] < mn) {
      mn = dp[n - 1][i];
      val = i;
    }
  }
  int b[n];
  b[n - 1] = ans[n - 1][val];
  for (i = (n - 2); i > (-1); i -= (1)) {
    val = val ^ F[b[i + 1]];
    b[i] = ans[i][val];
  }
  for (i = (0); i < (n); i += (1)) cout << b[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  pre();
  while (t--) {
    solve();
  }
  return 0;
}