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;
const int NAX = 60, inf = 1000000000;
vector<bool> sieve(NAX + 1, true);
struct Node {
  int ans;
  int edge;
  int bi;
  Node() { ans = edge = bi = -1; }
  Node(int ax, int bx, int cx) {
    ans = ax;
    edge = bx;
    bi = cx;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 2; i * i <= NAX; i++) {
    if (sieve[i])
      for (int j = i * i; j <= NAX; j += i) sieve[j] = false;
  }
  int c = 0;
  vector<int> primes;
  for (int i = 2; i <= NAX; i++) {
    if (sieve[i]) c++, primes.push_back(i);
  }
  vector<int> masks(NAX + 1);
  for (int i = 1; i <= NAX; i++) {
    for (int j = 0; j < c; j++) {
      if (i % primes[j] == 0) masks[i] |= (1 << j);
    }
  }
  int n;
  cin >> n;
  vector<vector<Node> > dp((1 << c) + 2,
                           vector<Node>(n + 2, Node(inf, -1, -1)));
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  a.insert(a.begin(), 1, 0);
  dp[0][0].ans = 0;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < (1 << c); i++) {
      if (dp[i][j].ans == inf) continue;
      for (int nm = 1; nm <= NAX; nm++) {
        if ((int)(masks[nm] & i) == 0) {
          int uni = masks[nm] | i;
          int sum = abs(nm - a[j + 1]) + dp[i][j].ans;
          if (dp[uni][j + 1].ans > sum) {
            dp[uni][j + 1] = Node(sum, i, nm);
          }
        }
      }
    }
  }
  int mini = inf;
  for (int i = 0; i < (1 << c); i++) mini = min(mini, dp[i][n].ans);
  for (int i = 0; i < (1 << c); i++) {
    if (dp[i][n].ans == mini) {
      vector<int> answer;
      answer.push_back(dp[i][n].bi);
      int posmask = dp[i][n].edge;
      for (int j = n - 1; j > 0; j--) {
        answer.push_back(dp[posmask][j].bi);
        posmask = dp[posmask][j].edge;
      }
      reverse(answer.begin(), answer.end());
      for (int i = 0; i < n; i++) cout << answer[i] << ' ';
      cout << '\n';
      return 0;
    }
  }
  return 0;
}