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> primes;
int factors[60];
int mem[101][1 << 17], par[101][1 << 17];
void printbin(int n) {
  for (int i = 17; i >= 0; i--) {
    if ((n & (1 << i)) != 0) {
      printf("1");
    } else {
      printf("0");
    }
  }
}
int main() {
  primes.push_back(2);
  primes.push_back(3);
  primes.push_back(5);
  for (int i = 6; i < 60; i++) {
    int n = i + 1;
    bool p = true;
    for (int j = 0; j < primes.size(); j++) {
      if (n % primes[j] == 0) {
        p = false;
        break;
      }
    }
    if (p) {
      primes.push_back(n);
    }
    n = i + 5;
    p = true;
    for (int j = 0; j < primes.size(); j++) {
      if (n % primes[j] == 0) {
        p = false;
        break;
      }
    }
    if (p) {
      primes.push_back(n);
    }
  }
  memset(factors, 0, sizeof(factors));
  for (int i = 2; i < 60; i++) {
    int t = i;
    for (int j = 0; j < primes.size(); j++) {
      while (t % primes[j] == 0) {
        t /= primes[j];
        factors[i] |= (1 << j);
      }
    }
  }
  memset(mem, -1, sizeof(mem));
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < (1 << 17); i++) {
    mem[0][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    for (int j = 1; j < 60; j++) {
      int mask = (~factors[j]) & ((1 << 17) - 1);
      for (int s = mask; s != 0; s = (s - 1) & (~factors[j])) {
        if (mem[i][s | factors[j]] == -1 ||
            mem[i - 1][s] + abs(j - a) < mem[i][s | factors[j]]) {
          mem[i][s | factors[j]] = mem[i - 1][s] + abs(j - a);
          par[i][s | factors[j]] = j;
        }
      }
    }
  }
  int ans = 1000000;
  int ansi = -1;
  for (int i = 0; i < (1 << 17); i++) {
    if (ans > mem[n][i]) {
      ans = mem[n][i];
      ansi = i;
    }
  }
  stack<int> s;
  int cur = (1 << 17) - 1;
  for (int i = n; i > 0; i--) {
    s.push(par[i][cur]);
    cur &= ~factors[par[i][cur]];
  }
  for (int i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%d", s.top());
    s.pop();
  }
  printf("\n");
  return 0;
}