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;
const int S = 1 << 17;
int mark[60], a[110];
int dp[110][S], road[110][S], pre[110][S], n, st, ans;
int bit_factor[60];
const int maxn = 100;
bool isprime[65];
int prime[65];
int len = 1;
stack<int> s;
int myabs(int x) {
  if (x < 0) {
    return -x;
  } else {
    return x;
  }
}
void sieve(int n) {
  for (int i = 0; i < n; i++) isprime[i] = 1;
  isprime[0] = isprime[1] = 0;
  for (int i = 2; i < n; i++)
    if (isprime[i]) {
      prime[len++] = i;
      for (int j = 2 * i; j < n; j += i) isprime[j] = 0;
    }
}
int main() {
  sieve(64);
  mark[2] = 1, mark[3] = 2, mark[5] = 3, mark[7] = 4, mark[11] = 5,
  mark[13] = 6, mark[17] = 7, mark[19] = 8, mark[23] = 9, mark[29] = 10;
  for (int i = 2; i <= 59; i++) {
    int x = i;
    int statue = 0;
    while (x != 1) {
      for (int j = 1; j <= 17; j++) {
        if (!(x % prime[j])) {
          x /= prime[j];
          statue |= 1 << (j - 1);
        }
      }
    }
    bit_factor[i] = statue;
  }
  scanf("%d", &n);
  {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    memset(dp, 0x3f, sizeof(dp));
    memset(road, 0, sizeof(dp));
    memset(pre, 0, sizeof(dp));
    dp[0][0] = 0;
    ans = 0x3f3f3f3f;
    for (int i = 1; i <= n; i++) {
      for (int s = 0; s < S; s++) {
        if (dp[i - 1][s] != 0x3f3f3f3f) {
          for (int j = 1; j <= 59; j++) {
            if (!(s & bit_factor[j])) {
              if (dp[i][s | bit_factor[j]] > dp[i - 1][s] + myabs(j - a[i])) {
                if (i == n && (ans > dp[i - 1][s] + myabs(j - a[i]))) {
                  ans = dp[i - 1][s] + myabs(j - a[i]);
                  st = s | bit_factor[j];
                }
                dp[i][s | bit_factor[j]] = dp[i - 1][s] + myabs(j - a[i]);
                road[i][s | bit_factor[j]] = j;
                pre[i][s | bit_factor[j]] = s;
              }
            }
          }
        }
      }
    }
    while (n) {
      s.push(road[n][st]);
      st = pre[n--][st];
    }
    while (!s.empty()) {
      printf("%d ", s.top());
      s.pop();
    }
    printf("\n");
  }
}