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;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char* x) { cerr << '\"' << x << '\"'; }
void __print(const string& x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V>& x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T& x) {
  int f = 0;
  cerr << '{';
  for (auto& i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const int M = 1e9 + 7;
unordered_map<int, int> primeind;
int primemask[100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int ind = 0;
  for (int i = 2; i <= 60; ++i) {
    bool f = true;
    for (int j = 2; j * j <= i; ++j) {
      if ((i % j) == 0) {
        f = false;
        break;
      }
    }
    if (f) {
      primeind[i] = ind++;
    }
  }
  int tmask = 1 << 17;
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  vector<vector<int>> dp(n + 1, vector<int>(tmask, 1e9));
  vector<vector<int>> prev(n + 1, vector<int>(tmask, -1));
  for (int i = 2; i <= 60; ++i) {
    int mask = 0;
    int ti = i;
    for (int j = 2; j * j <= i; ++j) {
      if ((i % j) == 0) {
        mask |= (1 << primeind[j]);
        while ((i % j) == 0) {
          i /= j;
        }
      }
    }
    if (i != 1) {
      mask |= (1 << primeind[i]);
    }
    i = ti;
    primemask[i] = mask;
  }
  dp[0][0] = 0;
  int amask = 0;
  for (int i = 1; i <= n; ++i) {
    for (int mask = 0; mask < tmask; ++mask) {
      for (int j = 1; j <= 60; ++j) {
        if ((primemask[j] & mask) != primemask[j]) {
          continue;
        }
        int temp = dp[i - 1][mask ^ primemask[j]] + abs(j - A[i - 1]);
        if (temp < dp[i][mask]) {
          prev[i][mask] = j;
          dp[i][mask] = temp;
        }
      }
      if (i == n) {
        if (dp[i][mask] < dp[i][amask]) {
          amask = mask;
        }
      }
    }
  }
  int i = n, j = amask;
  vector<int> ans;
  while (i > 0) {
    int temp = prev[i][j];
    ans.push_back(temp);
    j = primemask[temp] ^ j;
    --i;
  }
  reverse(ans.begin(), ans.end());
  for (int i : ans) {
    cout << i << " ";
  }
  cout << "\n";
  return 0;
}