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;
template <int MAX_RANGE>
class PrimeGenerator {
  static const int MAX = 46656;
  static const int LMT = 216;
  static const int LEN = 4830;
  unsigned base[MAX / 64], segment[MAX_RANGE / 64], primes[LEN];

 public:
  PrimeGenerator() { internal_sieve(); }
  int segmented_sieve(int a, int b, int *user) {
    unsigned i, j, k, cnt = (a <= 2 && 2 <= b) ? 1 : 0;
    if (a <= 2 && 2 <= b) {
      if (user) user[cnt - 1] = 2;
    }
    if (b < 2) return 0;
    if (a < 3) a = 3;
    if (a % 2 == 0) a++;
    memset(segment, 0, sizeof(segment));
    for (i = 0; ((primes[i]) * (primes[i])) <= b; i++) {
      j = primes[i] * ((a + primes[i] - 1) / primes[i]);
      if (j % 2 == 0) j += primes[i];
      for (k = primes[i] << 1; j <= b; j += k)
        if (j != primes[i])
          (segment[(j - a) >> 6] |= (1 << (((j - a) >> 1) & 31)));
    }
    if (b - a >= 0) {
      for (i = 0; i <= b - a; i += 2) {
        if (!(segment[i >> 6] & (1 << ((i >> 1) & 31)))) {
          if (user) user[cnt] = i + a;
          cnt++;
        }
      }
    }
    return cnt;
  }

 private:
  void internal_sieve() {
    unsigned i, j, k;
    for (i = 3; i < LMT; i += 2)
      if (!(base[i >> 6] & (1 << ((i >> 1) & 31))))
        for (j = i * i, k = i << 1; j < MAX; j += k)
          (base[j >> 6] |= (1 << ((j >> 1) & 31)));
    for (i = 3, j = 0; i < MAX; i += 2)
      if (!(base[i >> 6] & (1 << ((i >> 1) & 31)))) primes[j++] = i;
  }
};
int N;
int in[(105)];
int primes[61];
int dp[(105)][1 << 17];
vector<int> good_numbers[1 << 17];
int nx[61];
int pre[(105)][1 << 17];
int pre2[(105)][1 << 17];
void print(int ind, int ind2) {
  if (ind == 0) return;
  print(ind - 1, pre2[ind][ind2]);
  printf("%d ", pre[ind][ind2]);
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> in[i];
  PrimeGenerator<100> gen;
  int num_prime = gen.segmented_sieve(1, 60, primes);
  memset(dp, (0x3f3f3f3f), sizeof(dp));
  ;
  for (int j = 1; j <= 60; j++) {
    for (int k = 0; k < 17; k++) {
      if (j % primes[k] == 0) {
        nx[j] |= (1 << k);
      }
    }
  }
  for (int i = 0; i < 1 << 17; i++) {
    for (int j = 1; j <= 60; j++) {
      if ((i & nx[j]) == 0) {
        good_numbers[i].push_back(j);
      }
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 1 << 17; j++) {
      if (dp[i][j] != (0x3f3f3f3f)) {
        for (auto n : good_numbers[j]) {
          if (dp[i + 1][j | nx[n]] > dp[i][j] + abs(in[i] - n)) {
            dp[i + 1][j | nx[n]] = dp[i][j] + abs(in[i] - n);
            pre[i + 1][j | nx[n]] = n;
            pre2[i + 1][j | nx[n]] = j;
          }
        }
      }
    }
  }
  int minn = (0x3f3f3f3f);
  int first = 0;
  for (int i = 0; i < 1 << 17; i++) {
    if (dp[N][i] < minn) {
      minn = dp[N][i];
      first = i;
    }
  }
  print(N, first);
  return 0;
}