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 n, a[109], f[60], assign, value, mask = (1 << 18) - 1;
int dp[109][1 << 18];
int dp2[109][1 << 18];
void init() {
  for (int i = 2; i < 60; i++) {
    if (!f[i]) {
      for (int j = 2 * i; j < 60; j += i) f[j] = 1;
    }
  }
  for (int i = 1, j = 0; i < 60; i++)
    if (!f[i])
      f[i] = j++;
    else
      f[i] = -1;
}
int calc(int n) {
  int ret = 0;
  for (int i = 1; i < 60; i++)
    if (f[i] != -1 && n % i == 0) ret |= (1 << f[i]);
  return ret;
}
int ans = 60000;
int main() {
  cin >> n;
  init();
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 1; i < 60; i++) {
    int t = calc(i);
    dp[0][t] = min(dp[0][t], abs(a[0] - i));
    if (dp[0][t] == abs(a[0] - i)) dp2[0][t] = i;
  }
  ans = INT_MAX;
  int res = 0;
  for (int i = 1; i < n; i++) {
    memset(dp[i], 0x3f, sizeof(dp[i]));
    for (int j = 1; j < 60; j++) {
      assign = calc(j);
      value = ((~assign) & mask) | 1;
      for (int k = value;; k = (k - 1) & value) {
        if (dp[i - 1][k | 1] != 4557430888798830399ll) {
          dp[i][k | 1 | assign] =
              min(dp[i][k | 1 | assign], abs(j - a[i]) + dp[i - 1][k | 1]);
          if (i == n - 1) {
            if (ans > dp[i][k | 1 | assign] &&
                dp[i][k | 1 | assign] == abs(j - a[i]) + dp[i - 1][k | 1]) {
              ans = dp[i][k | 1 | assign];
              res = k | 1 | assign;
            }
          }
          if (dp[i][k | 1 | assign] == abs(j - a[i]) + dp[i - 1][k | 1])
            dp2[i][k | 1 | assign] = j;
        }
        if (k == 0) break;
      }
    }
  }
  vector<int> v(n, 0);
  for (int i = n - 1; i >= 0; i--) {
    v[i] = dp2[i][res];
    res ^= calc(dp2[i][res]);
    res |= 1;
  }
  for (int i = 0; i < n; i++) cout << v[i] << " ";
  cout << endl;
  return 0;
}