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 N = 105;
const int oo = 99999;
int n, a[N], f[N][(1 << 18)], bit[N], p[N];
vector<int> b;
int get_bit(int a) {
  int s = 2, ans = 0;
  ;
  while (a > 1) {
    while (a % s == 0) {
      a /= s;
      ans |= (1 << p[s]);
    }
    ++s;
  }
  return ans;
}
bool ok(int a) {
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
void init() {
  int t = 0;
  for (int i = 2; i <= 60; i++)
    if (ok(i)) {
      p[i] = t;
      ++t;
    }
  for (int i = 1; i <= 60; i++) bit[i] = get_bit(i);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  init();
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= (1 << 17); j++) f[i][j] = oo;
  f[0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int mask = 0; mask < (1 << 17); mask++) {
      if (f[i - 1][mask] < oo) {
        for (int num = 1; num <= 60; num++) {
          if (!(mask & bit[num])) {
            f[i][bit[num] | mask] =
                min(f[i][bit[num] | mask], f[i - 1][mask] + abs(num - a[i]));
          }
        }
      }
    }
  int min_cur = oo, bit_cur;
  for (int i = 0; i < (1 << 17); i++) {
    if (min_cur > f[n][i]) {
      bit_cur = i;
      min_cur = f[n][i];
    }
  }
  for (int i = n; i > 0; i--) {
    for (int num = 1; num <= 60; num++) {
      int x = abs(num - a[i]);
      if ((bit_cur | bit[num]) == bit_cur) {
        if (f[i - 1][bit_cur - bit[num]] + x == f[i][bit_cur]) {
          bit_cur = bit_cur - bit[num];
          min_cur = f[i][bit_cur] - x;
          b.push_back(num);
          break;
        }
      }
    }
  }
  for (int i = (int)b.size() - 1; i >= 0; i--) cout << b[i] << ' ';
  return 0;
}