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 nmax = 110;
const int m = 60;
const int k = 10;
const int p[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
int primes[nmax];
vector<int> decompose[m];
bool notuse[m];
int n;
int a[nmax];
int d[1 << k][nmax][nmax];
int path[1 << k][nmax][nmax];
int abs(int x) { return x < 0 ? -x : x; }
int dfs(int pattern, int cp, int pos) {
  if (pos == n) {
    d[pattern][cp][pos] = 0;
    return 0;
  }
  if (d[pattern][cp][pos] >= 0) return d[pattern][cp][pos];
  int result = -1;
  if (pattern != (1 << k)) {
    for (int i = 2; i < m; ++i) {
      if (notuse[i]) continue;
      int new_pattern = pattern;
      int used_primes = 0;
      bool forbidden = false;
      for (int j = 0; j < decompose[i].size(); ++j) {
        if (pattern & (1 << decompose[i][j])) {
          forbidden = true;
          break;
        }
        new_pattern += (1 << decompose[i][j]);
        ++used_primes;
      }
      if (forbidden) continue;
      int value = dfs(new_pattern, cp + 1, pos + 1) + abs(a[pos] - i);
      if (result == -1 || value < result) {
        result = value;
        path[pattern][cp][pos] = i;
      }
    }
  }
  int value = dfs(pattern, cp + 1, pos + 1) + (a[pos] - 1);
  if (result == -1 || value < result) {
    result = value;
    path[pattern][cp][pos] = 1;
  }
  value = dfs(pattern, cp, pos + 1) + abs(primes[pos - cp] - a[pos]);
  if (result == -1 || value < result) {
    result = value;
    path[pattern][cp][pos] = 1000;
  }
  d[pattern][cp][pos] = result;
  return result;
}
bool is_prime(int x) {
  for (int i = 2; i < x; ++i)
    if (x % i == 0) return false;
  return true;
}
void compute_primes() {
  int current = 31;
  int pos = 0;
  while (pos < nmax) {
    while (!is_prime(current)) ++current;
    primes[pos] = current;
    ++current;
    ++pos;
  }
}
void compute_decomposition() {
  for (int i = 2; i < m; ++i) {
    int cur = i;
    for (int j = 0; j < k; ++j) {
      if (cur % p[j] == 0) {
        while (cur % p[j] == 0) cur /= p[j];
        decompose[i].push_back(j);
        if (cur == 1) break;
      }
    }
    if (cur != 1) {
      decompose[i].clear();
      notuse[cur] = true;
    }
  }
}
int main() {
  memset(a, 0, sizeof(a));
  memset(d, -1, sizeof(d));
  memset(notuse, 0, sizeof(notuse));
  compute_primes();
  compute_decomposition();
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int result = dfs(0, 0, 0);
  int pattern = 0;
  int cp = 0;
  int verify = 0;
  for (int pos = 0; pos < n; ++pos) {
    if (path[pattern][cp][pos] == 1000) {
      printf("%d ", primes[pos - cp]);
      verify += abs(a[pos] - primes[pos - cp]);
    } else {
      int v = path[pattern][cp][pos];
      verify += abs(a[pos] - v);
      printf("%d ", v);
      int new_pattern = pattern;
      for (int j = 0; j < decompose[v].size(); ++j) {
        assert((new_pattern & (1 << decompose[v][j])) == 0);
        new_pattern += (1 << decompose[v][j]);
      }
      pattern = new_pattern;
      ++cp;
    }
  }
  assert(result == verify);
  printf("\n");
  return 0;
}