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>
template <typename T>
void read(T &x);
template <typename T>
void read(T &x, T &y);
template <typename T>
void read(T &x, T &y, T &z);
template <typename T>
void write(T x);
template <typename T>
void writeC(T x);
template <typename T>
void writeN(T x);
int d[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int a[205], b[205], f[205][1 << 17], S[105], pre[205][1 << 17], n, v[1 << 17],
    tl;
void output(int x, int y) {
  if (x == 1) return;
  b[x - 1] = pre[x][y];
  output(x - 1, y ^ S[pre[x][y]]);
}
signed main() {
  std::memset(f, 63, sizeof(f));
  f[1][0] = 0;
  read(n);
  for (int i = 1; i <= (n); ++i) read(a[i]);
  ;
  for (int i = 1; i <= 60; ++i) {
    for (int j = 0; j < 16; ++j) {
      if (i % d[j] == 0) S[i] |= (1 << j);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int mask = 0; mask < (1 << 16); ++mask) {
      for (int j = 1; j <= 60; ++j) {
        if (mask & S[j]) continue;
        int w = f[i][mask] + std::abs(j - a[i]);
        if (f[i + 1][mask | S[j]] > w) {
          f[i + 1][mask | S[j]] = w;
          pre[i + 1][mask | S[j]] = j;
        }
      }
    }
  }
  int y = 0, ans = 1e9;
  for (int mask = 0; mask < (1 << 17); ++mask) {
    if (f[n + 1][mask] < ans) {
      y = mask;
      ans = f[n + 1][mask];
    }
  }
  output(n + 1, y);
  for (int i = 1; i <= n; ++i) write(b[i]);
  return 0;
}
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  T flag = 1;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -flag;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= flag;
}
template <typename T>
void read(T &x, T &y) {
  read(x);
  read(y);
}
template <typename T>
void read(T &x, T &y, T &z) {
  read(x);
  read(y);
  read(z);
}
template <typename T>
void writeC(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) writeC(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void write(T x) {
  writeC(x);
  putchar(' ');
}
template <typename T>
void writeN(T x) {
  writeC(x);
  puts("");
}