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;
inline int read() {
  static int r, sign;
  static char c;
  r = 0, sign = 1;
  do c = getchar();
  while (c != '-' && (c < '0' || c > '9'));
  if (c == '-') sign = -1, c = getchar();
  while (c >= '0' && c <= '9') r = r * 10 + (int)(c - '0'), c = getchar();
  return sign * r;
}
template <typename T>
inline void print(T *a, int n) {
  for (int i = 1; i < n; ++i) cout << a[i] << " ";
  cout << a[n] << endl;
}
int n, a[100 + 1], f[100 + 1][1 << 16], from[100 + 1][1 << 16], mask[100 + 1],
    ans[100 + 1];
const int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int main(int argc, char *argv[]) {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= 100; ++i) {
    int m = 0;
    for (int j = 0; j < 16; ++j)
      if (!(i % p[j])) m |= 1 << j;
    mask[i] = m;
  }
  for (int j = 1; j < (1 << 16); ++j) f[0][j] = INT_MAX / 2;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (1 << 16); ++j) f[i][j] = INT_MAX / 2;
    for (int k = 1; k < 60; ++k) {
      int val = abs(a[i] - k);
      for (int j = 0; j < (1 << 16); ++j) {
        if ((j & mask[k]) != mask[k]) continue;
        if (f[i][j] > f[i - 1][j ^ mask[k]] + val) {
          f[i][j] = f[i - 1][j ^ mask[k]] + val;
          from[i][j] = k;
        }
      }
    }
  }
  int m = 0, val = INT_MAX;
  for (int j = 0; j < (1 << 16); ++j)
    if (val > f[n][j]) val = f[n][j], m = j;
  ans[n] = from[n][m];
  for (int i = n - 1; i > 0; --i) {
    m = m ^ mask[ans[i + 1]];
    ans[i] = from[i][m];
  }
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  fclose(stdin);
  fclose(stdout);
  return 0;
}