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 DS = 11;
int N;
const int S = 1 << DS;
int dp[100][100][S];
int arr[] = {2,  3,  5,  7,  11, 13, 17, 19, 23, 29,
             31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
int uses[60];
pair<int, int> diffs[100];
int answer[100];
vector<int> NV;
bool prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int solve(int p, int vs, int s) {
  if (p >= N) return 0;
  int& ans = dp[p][vs][s];
  if (ans >= 0) return ans;
  ans = ((int)1e9);
  for (int i = (0); i < (60); i++)
    if ((s & uses[i]) == uses[i]) {
      ans = min(abs(i - diffs[p].first) + solve(p + 1, vs, s ^ uses[i]), ans);
    }
  ans = min(ans, diffs[p].first - 1 + solve(p + 1, vs, s));
  ans = min(ans, NV[vs] - diffs[p].first + solve(p + 1, vs + 1, s));
  return ans;
}
void extract(int p, int vs, int s) {
  if (p >= N) return;
  int ans = solve(p, vs, s);
  for (int i = (0); i < (60); i++)
    if ((s & uses[i]) == uses[i]) {
      if (abs(i - diffs[p].first) + solve(p + 1, vs, s ^ uses[i]) == ans) {
        answer[p] = i;
        extract(p + 1, vs, s ^ uses[i]);
        return;
      }
    }
  if (diffs[p].first - 1 + solve(p + 1, vs, s) == ans) {
    answer[p] = 1;
    extract(p + 1, vs, s);
    return;
  }
  if (ans == NV[vs] - diffs[p].first + solve(p + 1, vs + 1, s)) {
    answer[p] = NV[vs];
    extract(p + 1, vs + 1, s);
    return;
  }
  assert(false);
}
int main() {
  for (int i = (0); i < (100); i++)
    for (int k = (0); k < (100); k++)
      for (int j = (0); j < (S); j++) dp[i][k][j] = -1;
  for (int i = (0); i < (60); i++) {
    uses[i] = 0;
    for (int j = (0); j < (18); j++) {
      if (i % arr[j] == 0) {
        uses[i] |= 1 << j;
      }
    }
  }
  scanf("%d", &(N));
  for (int i = (0); i < (N); i++) {
    scanf("%d", &(diffs[i].first));
    diffs[i].second = i;
  }
  sort(diffs, diffs + N);
  for (int i = arr[DS - 1] + 1; NV.size() < N; i++)
    if (prime(i)) NV.push_back(i);
  extract(0, 0, (1 << DS) - 1);
  for (int i = (0); i < (N); i++) {
    diffs[i].first = diffs[i].second;
    diffs[i].second = i;
  }
  sort(diffs, diffs + N);
  for (int i = (0); i < (N); i++) {
    printf("%d ", answer[diffs[i].second]);
  }
  printf("\n");
}