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 ini() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inl() {
  long long x;
  scanf("%lld", &x);
  return x;
}
void file_mamager() {}
int arr[105], mask[105], dp[105][1 << 17];
pair<int, int> path[105][1 << 17];
vector<int> primes;
void gen() {
  for (int i = 2; i <= 60; i++) {
    bool is = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        is = false;
        break;
      }
    }
    if (is) primes.push_back(i);
  }
}
void bit_rep(int x) {
  for (int i = 0; i < 10; i++) cout << ((x >> i) & 1);
  cout << "\n";
}
int main() {
  gen();
  int n = ini();
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << 17); j++) dp[i][j] = 1e8;
  }
  for (int i = 1; i <= n; i++) arr[i] = ini();
  for (int i = 1; i <= 60; i++) {
    int x = 0, y = i;
    for (int j = 0; j < 17; j++) {
      if (y % primes[j] == 0) {
        x |= (1 << j);
        while (y % primes[j] == 0) y /= primes[j];
      }
    }
    mask[i] = x;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 60; j++) {
      for (int k = 0; k < (1 << 17); k++) {
        if ((k & mask[j]) == mask[j]) {
          if (dp[i - 1][k ^ mask[j]] + abs(arr[i] - j) < dp[i][k]) {
            dp[i][k] = dp[i - 1][k ^ mask[j]] + abs(arr[i] - j);
            path[i][k] = {(k ^ mask[j]), j};
          }
        }
      }
    }
  }
  int mn = 1e8;
  int x = (1 << 17) - 1;
  for (int k = 0; k < (1 << 17); k++) {
    if (dp[n][k] < mn) {
      mn = dp[n][k];
      x = k;
    }
  }
  vector<int> ans;
  for (int i = n; i >= 1; i--) {
    ans.push_back(path[i][x].second);
    x = path[i][x].first;
  }
  reverse(ans.begin(), ans.end());
  for (int xx : ans) cout << xx << " ";
  cout << "\n";
  return 0;
}