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 long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 110;
const int SN = 1 << 16;
int n;
int a[MAXN];
int dp[MAXN][SN + 7];
int s[60];
pair<int, int> route[MAXN][SN + 7];
int prime[20] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
inline int getstate(int a) {
  int u = 0;
  for (int i = 0; i < 16; i++) {
    while (a % prime[i] == 0) {
      a /= prime[i];
      u |= (1 << i);
    }
  }
  return u;
}
int GetNumOfOne(int x) {
  int count = 0;
  while (x) {
    count++;
    x = x & (x - 1);
  }
  return count;
}
void print(int last, int id) {
  if (id == 1) {
    cout << route[id][last].second;
    return;
  }
  print(route[id][last].first, id - 1);
  cout << ' ' << route[id][last].second;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  for (int i = 1; i < 60; i++) s[i] = getstate(i);
  cin >> n;
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i < n + 1; i++) cin >> a[i];
  for (int i = 1; i < n + 1; i++)
    for (int j = 0; j < SN; j++)
      if (GetNumOfOne(j) < i) {
        if (dp[i][j] > dp[i - 1][j] + a[i] - 1) {
          dp[i][j] = dp[i - 1][j] + a[i] - 1;
          route[i][j].first = j;
          route[i][j].second = 1;
        }
        for (int k = 0; k < 60; k++)
          if ((j & s[k]) == 0) {
            if (dp[i][j | s[k]] > dp[i - 1][j] + abs(k - a[i])) {
              dp[i][j | s[k]] = dp[i - 1][j] + abs(k - a[i]);
              route[i][j | s[k]].first = j;
              route[i][j | s[k]].second = k;
            }
          }
      }
  int ans = INF;
  int last;
  for (int j = 0; j < (1 << 16); j++)
    if (ans > dp[n][j]) {
      ans = dp[n][j];
      last = j;
    }
  print(last, n);
  cout << endl;
  return 0;
}