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;
int n, a[105], v[105], b[105];
bool p[105];
vector<int> u;
int f[105][(1 << 17) + 5], trace[105][(1 << 17) + 5];
vector<int> x[300005];
bool ok(int i, int j) {
  if (i < j) return 0;
  int k = i - j;
  return (k & j) == 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= 59; i++) p[i] = 1;
  for (int i = 2; i <= 59; i++)
    if (p[i]) {
      for (int j = 2; j <= 59 / i; j++) p[i * j] = 0;
    }
  for (int i = 2; i <= 59; i++)
    if (p[i]) u.push_back(i);
  for (int i = 2; i <= 59; i++)
    for (int j = 0; j < int(u.size()); j++)
      if (i % u[j] == 0) {
        v[i] += (1 << j);
      }
  for (int t = 0; t <= (1 << 17) - 1; t++)
    for (int j = 2; j <= 59; j++)
      if (ok(t, v[j])) x[t].push_back(j);
  for (int i = 1; i <= n; i++)
    for (int t = 0; t <= (1 << 17) - 1; t++) {
      f[i][t] = f[i - 1][t] + a[i] - 1;
      trace[i][t] = 1;
      for (int k = 0; k < int(x[t].size()); k++) {
        int j = x[t][k];
        if (f[i][t] > f[i - 1][t - v[j]] + abs(a[i] - j)) {
          f[i][t] = f[i - 1][t - v[j]] + abs(a[i] - j);
          trace[i][t] = j;
        }
      }
    }
  int mn = 1000000100;
  int cur;
  for (int t = 0; t <= (1 << 17) - 1; t++)
    if (f[n][t] < mn) {
      mn = f[n][t];
      cur = t;
    }
  for (int i = n; i >= 1; i--) {
    b[i] = trace[i][cur];
    cur -= v[b[i]];
  }
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}