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> p[65];
int prime[65];
int get_prime() {
  int k = 0;
  for (int i = 0; i < 59; i++) p[i].clear();
  for (int i = 2; i < 59; i++) {
    if (p[i].size() == 0) {
      prime[i] = k;
      k++;
      for (int j = i; j < 59; j += i) {
        p[j].push_back(i);
      }
    }
  }
  for (int i = 1; i < 59; i++)
    for (int j = 0; j < p[i].size(); j++) p[i][j] = prime[p[i][j]];
  return k;
}
int dp[105][65540];
int num[105][65540];
int pre[105][65540];
int a[105], n;
void compute(int i, int j, int number, int abs) {
  bitset<17> b0(j);
  for (int k = 0; k < p[number].size(); k++)
    if (b0[p[number][k]] == 1) {
      return;
    }
  for (int k = 0; k < p[number].size(); k++) {
    b0[p[number][k]] = 1;
  }
  int t = b0.to_ulong();
  if (dp[i][t] == -1 || dp[i][t] > dp[i - 1][j] + abs) {
    dp[i][t] = dp[i - 1][j] + abs;
    num[i][t] = number;
    pre[i][t] = j;
  }
}
void output(int i, int j) {
  if (i == 1) {
    cout << num[i][j];
    return;
  }
  output(i - 1, pre[i][j]);
  cout << " " << num[i][j];
}
int main() {
  int k = get_prime();
  while (cin >> n) {
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < 65540; j++)
        if (dp[i - 1][j] >= 0) {
          for (int count = 1; count <= a[i]; count++)
            compute(i, j, count, a[i] - count);
          for (int count = a[i] + 1; count < a[i] * 2 - 1; count++)
            compute(i, j, count, count - a[i]);
        }
    }
    int Min = 30000, j = 0;
    for (int i = 0; i < 65540; i++)
      if (dp[n][i] >= 0 && dp[n][i] < Min) {
        Min = dp[n][i];
        j = i;
      }
    output(n, j);
    cout << endl;
  }
  return 0;
}