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;
vector<int> prime;
bool vis[65];
const int up = (1 << 17);
const int max_n = 105;
int a[max_n], s[max_n], dp[max_n][up + 5], path[max_n][up + 5];
void print(int x) {
  vector<int> res;
  while (x > 0) {
    res.push_back(x % 2);
    x >>= 1;
  }
  reverse(res.begin(), res.end());
  for (int i : res) printf("%d", i);
  puts("");
}
int main() {
  for (int i = 2; i <= 60; i++) {
    if (!vis[i]) prime.push_back(i);
    for (int j = 0; j < prime.size() && i * prime[j] <= 60; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
  for (int i = 1; i < 60; i++) {
    s[i] = 0;
    int now = i;
    for (int j = 0; j < prime.size(); j++) {
      while (now % prime[j] == 0) {
        s[i] |= (1 << j);
        now /= prime[j];
      }
    }
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(path, -1, sizeof path);
  dp[0][0] = 0;
  path[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < up; j++)
      if (path[i - 1][j] != -1) {
        for (int k = 1; k < 60; k++) {
          if (j & s[k]) continue;
          int nxt = j | s[k];
          if (path[i][nxt] == -1 || dp[i][nxt] > dp[i - 1][j] + abs(k - a[i])) {
            dp[i][nxt] = dp[i - 1][j] + abs(k - a[i]);
            path[i][nxt] = k;
          }
        }
      }
  }
  int ans = 1e9, pos = -1;
  for (int i = 0; i < up; i++) {
    if (dp[n][i] < ans && path[n][i] != -1) {
      ans = dp[n][i];
      pos = i;
    }
  }
  vector<int> res;
  int now = n;
  while (now >= 1) {
    res.push_back(path[now][pos]);
    pos ^= s[path[now][pos]];
    now--;
  }
  reverse(res.begin(), res.end());
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  puts("");
  return 0;
}