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 arr[120];
int memo[120][(1 << 17)];
int n;
bitset<70> bs;
map<int, int> pr;
vector<int> primes;
vector<int> masks;
int dp(int idx, int mask) {
  if (idx == n) return memo[idx][mask] = 0;
  if (memo[idx][mask] != -1) return memo[idx][mask];
  int ans = dp(idx + 1, mask) + abs(arr[idx] - 1);
  for (int i = 2; i <= 60; i++) {
    if ((mask & masks[i]) == 0) {
      ans = min(ans, dp(idx + 1, mask | masks[i]) + abs(arr[idx] - i));
    }
  }
  return memo[idx][mask] = ans;
}
void sieve() {
  bs.set();
  int ct = 0;
  for (int i = 2; i <= 60; i++) {
    if (bs[i]) {
      primes.push_back(i);
      pr[i] = ct++;
      for (int j = i * i; j <= 60; j += i) {
        bs[j] = false;
      }
    }
  }
}
void printPath(int idx, int mask) {
  if (idx == n) return;
  for (int i = 1; i <= 60; i++) {
    if ((mask & masks[i]) == 0) {
      if (memo[idx][mask] ==
          (memo[idx + 1][mask | masks[i]] + abs(arr[idx] - i))) {
        printf("%d ", i);
        printPath(idx + 1, mask | masks[i]);
        break;
      }
    }
  }
}
int main(void) {
  sieve();
  masks.push_back(0);
  masks.push_back(0);
  for (int i = 2; i <= 60; i++) {
    int z = 0;
    if (bs[i]) {
      z |= (1 << pr[i]);
      masks.push_back(z);
      continue;
    }
    int temp = i;
    for (int j = 0; j < (int)primes.size(); j++) {
      int p = primes[j];
      if (p * p > temp) break;
      while (temp % p == 0) {
        temp /= p;
        z |= (1 << pr[p]);
      }
    }
    if (temp > 1) {
      z |= (1 << pr[temp]);
    }
    masks.push_back(z);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  memset(memo, -1, sizeof(memo));
  dp(0, 0);
  printPath(0, 0);
  return 0;
}