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 main() {
  int n;
  scanf("%d", &n);
  int arr[105];
  int greatest = 0;
  for (int i = int(1); i < int(n + 1); i++) {
    scanf("%d", arr + i);
    greatest = max(greatest, arr[i]);
  }
  vector<int> primes;
  for (int i = int(2); i < int(2 * greatest); i++) {
    bool prime = true;
    for (int j = int(2); j < int(i); j++) {
      if (i % j == 0) {
        prime = false;
        break;
      }
    }
    if (prime) {
      primes.push_back(i);
    }
  }
  int f[105] = {0};
  for (int i = int(1); i < int(2 * greatest); i++) {
    for (int j = int(0); j < int(primes.size()); j++) {
      if (i % primes[j] == 0) {
        f[i] |= (1 << j);
      }
    }
  }
  int ps = primes.size();
  static int dp[105][1 << 17];
  memset(dp, 0x3F, sizeof dp);
  static tuple<int, int, int> father[105][1 << 17];
  memset(father, -1, sizeof father);
  for (int i = int(0); i < int(1 << ps); i++) {
    dp[0][i] = 0;
  }
  for (int i = int(1); i < int(n + 1); i++) {
    for (int j = int(1); j < int(2 * greatest); j++) {
      int mask = (~f[j]) & ((1 << ps) - 1);
      for (int submask = mask;; submask = (submask - 1) & mask) {
        if (dp[i][submask | f[j]] > dp[i - 1][submask] + abs(arr[i] - j)) {
          dp[i][submask | f[j]] = dp[i - 1][submask] + abs(arr[i] - j);
          father[i][submask | f[j]] = make_tuple(i - 1, submask, j);
        }
        if (submask == 0) {
          break;
        }
      }
    }
  }
  int ans = 1 << 30;
  pair<int, int> best = make_pair(-1, -1);
  for (int i = int(0); i < int(1 << ps); i++) {
    if (ans > dp[n][i]) {
      ans = dp[n][i];
      best = make_pair(n, i);
    }
  }
  vector<int> guys;
  tuple<int, int, int> cur = make_tuple(best.first, best.second, -1);
  while (get<0>(cur) > 0) {
    int ff = get<0>(cur);
    int s = get<1>(cur);
    auto prev = father[ff][s];
    int t = get<2>(prev);
    guys.push_back(t);
    cur = prev;
  }
  for (int i = int(guys.size() - 1); i >= int(0); i--) {
    printf("%d ", guys[i]);
  }
  printf("\n");
  return 0;
}