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 MAX_N = 120;
const int MAX_A = 65;
const int INF = 0x3f3f3f3f;
int seq_a[MAX_N];
int seq_b[MAX_N];
int f[MAX_N][1 << 18];
int path[MAX_N][1 << 18];
int prime[20];
int factor_bits[MAX_A];
int num;
int n;
bool is_prime(int a) {
  for (int i = 2; i <= a / 2; i++) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}
int make_factor(int a) {
  int ret = 0;
  for (int i = 0; i < num; i++) {
    ret <<= 1;
    if (a % prime[i] == 0) {
      ret = ret | 1;
    }
  }
  return ret;
}
void init() {
  num = 0;
  for (int i = 2; i <= 60; i++) {
    if (is_prime(i)) {
      prime[num++] = i;
    }
  }
  for (int i = 1; i < 60; i++) {
    factor_bits[i] = make_factor(i);
  }
}
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &seq_a[i]);
  }
}
void work() {
  memset(f, -1, sizeof(f));
  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << num); j++) {
      if (f[i][j] == -1) continue;
      for (int k = 1; k < 60; k++) {
        if ((j & factor_bits[k]) != 0) continue;
        if (f[i + 1][j | factor_bits[k]] == -1 ||
            f[i + 1][j | factor_bits[k]] > f[i][j] + abs(seq_a[i + 1] - k)) {
          f[i + 1][j | factor_bits[k]] = f[i][j] + abs(seq_a[i + 1] - k);
          path[i + 1][j | factor_bits[k]] = k;
        }
      }
    }
  }
  int ans = INF;
  int temp;
  for (int i = 0; i < (1 << num); i++) {
    if (f[n][i] == -1) continue;
    if (ans > f[n][i]) {
      ans = f[n][i];
      temp = i;
    }
  };
  ;
  for (int i = n; i > 0; i--) {
    seq_b[i] = path[i][temp];
    if ((factor_bits[path[i][temp]] | temp) != temp)
      ;
    ;
    temp -= factor_bits[path[i][temp]];
  }
  for (int i = 1; i <= n; i++) {
    if (i != 1) putchar(' ');
    printf("%d", seq_b[i]);
  }
}
int main() {
  init();
  input();
  work();
  return 0;
}