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> primes;
int dp[101][1 << 18], n, a[111], man, ansd[111], loc[100];
vector<int> fact[100];
int rec(int i, int mask) {
  if (i == n) return 0;
  if (dp[i][mask] != 1000000000) return dp[i][mask];
  int dif = abs(a[i] - 1);
  int ans = rec(i + 1, mask) + dif;
  for (int j = 2; j <= 60; j++) {
    int k;
    for (k = 0; k < fact[j].size(); k++)
      if (mask & (1 << fact[j][k])) break;
    if (k != (int)fact[j].size()) continue;
    int d = abs(a[i] - j);
    if (d <= dif) {
      int msk = mask;
      for (k = 0; k < fact[j].size(); k++) msk = msk | (1 << fact[j][k]);
      ans = min(ans, rec(i + 1, msk) + d);
    }
  }
  return dp[i][mask] = ans;
}
void reccons(int i, int mask, int m) {
  if (i == n) return;
  int dif = abs(a[i] - 1);
  if (rec(i + 1, mask) == m - dif) {
    ansd[i] = 1;
    reccons(i + 1, mask, m - dif);
    return;
  }
  for (int j = 2; j <= 60; j++) {
    int k;
    for (k = 0; k < fact[j].size(); k++)
      if (mask & (1 << fact[j][k])) break;
    if (k != (int)fact[j].size()) continue;
    int d = abs(a[i] - j);
    if (d > dif) continue;
    int msk = mask;
    for (k = 0; k < fact[j].size(); k++) msk = msk | (1 << fact[j][k]);
    if (rec(i + 1, msk) == m - d) {
      ansd[i] = j;
      reccons(i + 1, msk, m - d);
      return;
    }
  }
}
int main() {
  int i, j, t;
  for (i = 2; i <= 60; i++) {
    for (j = 2; j < i; j++)
      if (i % j == 0) break;
    if (j == i) primes.push_back(i);
  }
  for (i = 0; i < 17; i++) loc[primes[i]] = i;
  for (i = 2; i <= 60; i++) {
    for (j = 0; j < 17; j++)
      if (i % primes[j] == 0) fact[i].push_back(j);
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i <= n; i++)
    for (j = 0; j < (1 << 17); j++) dp[i][j] = 1000000000;
  man = rec(0, 0);
  reccons(0, 0, man);
  for (i = 0; i < n; i++) printf("%d ", ansd[i]);
  printf("\n");
  return 0;
}