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>
int prime[20], binary[60];
int sum[100][1 << 10][7];
struct Node {
  int value, last_state, last_used;
} num[100][1 << 10][7];
void PrintAns(int n, int state, int used) {
  if (n < 0) {
    return;
  }
  PrintAns(n - 1, num[n][state][used].last_state,
           num[n][state][used].last_used);
  if (n != 0) {
    printf(" ");
  }
  printf("%d", num[n][state][used].value);
}
inline int abs(int o) {
  if (o < 0) {
    o = -o;
  }
  return o;
}
int main() {
  prime[0] = 0;
  for (int i = 2; i < 59; i++) {
    bool check = false;
    for (int j = 2; j <= i / 2; j++)
      if (i % j == 0) check = true;
    if (!check) prime[++prime[0]] = i;
  }
  memset(sum, 0xff, sizeof(sum));
  for (int i = 2; i < 59; i++) {
    binary[i] = 0;
    for (int j = 1; j <= 10; j++)
      if (i % prime[j] == 0) binary[i] |= (1 << (j - 1));
  }
  int turn = 0;
  memset(sum, 0xff, sizeof(sum));
  int n;
  scanf("%d", &n);
  int a[110];
  int tot = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++)
    if (i == 0) {
      for (int j = 1; j < 59; j++)
        if ((binary[j] == 0) && (j > 1)) {
          sum[i][0][1] = prime[11] - a[i];
          num[i][0][1].value = prime[11];
        } else {
          int temp = abs(j - a[i]);
          if ((sum[i][binary[j]][0] == -1) || (sum[i][binary[j]][0] > temp)) {
            sum[i][binary[j]][0] = temp;
            num[i][binary[j]][0].value = j;
          }
        }
    } else {
      for (int j = 0; j < 1024; j++)
        for (int k = 0; k < 7; k++)
          if (sum[i - 1][j][k] != -1)
            for (int l = 1; l < 59; l++)
              if ((binary[l] & j) == 0) {
                int state = (binary[l] | j), used = k, diff = 0;
                int temp = l;
                if ((binary[l] == 0) && (l > 1)) {
                  used++;
                  if (used > 6) {
                    continue;
                  }
                  diff = prime[used + 10] - a[i];
                  temp = prime[used + 10];
                } else {
                  diff = abs(l - a[i]);
                }
                diff += sum[i - 1][j][k];
                if ((sum[i][state][used] == -1) ||
                    (sum[i][state][used] > diff)) {
                  sum[i][state][used] = diff;
                  num[i][state][used].value = temp;
                  num[i][state][used].last_state = j;
                  num[i][state][used].last_used = k;
                }
              }
    }
  int ans_sum = 1e9, state = 0, used = 0;
  for (int i = 0; i < 1024; i++)
    for (int j = 0; j < 7; j++)
      if ((sum[n - 1][i][j] > -1) && (sum[n - 1][i][j] < ans_sum)) {
        ans_sum = sum[n - 1][i][j];
        state = i;
        used = j;
      }
  PrintAns(n - 1, state, used);
  printf("\n");
  return 0;
}