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 pnum = 16;
int p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int mask[60];
int a[100000];
int t[100000];
int b[100000];
bool cmp(int i, int j) { return a[i] > a[j]; }
void init() {
  for (int i = 1; i < 59; i++) {
    mask[i] = 0;
    for (int j = 0; j < pnum; j++)
      if (i % p[j] == 0) mask[i] += (1 << j);
  }
}
int dp[17][(1 << 17)], run[17][(1 << 17)], from[17][(1 << 17)];
int abs(int x) { return (x < 0) ? -x : x; }
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), t[i] = i;
  std::stable_sort(t, t + n, cmp);
  int num = 0;
  for (int i = 0; i < n && i < pnum; i++) {
    if (a[t[i]] > 1)
      num++;
    else
      break;
  }
  for (int i = 0; i <= num; i++)
    for (int j = 0; j < (1 << pnum); j++) run[i][j] = false;
  run[0][0] = true;
  dp[0][0] = 0;
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < (1 << pnum); j++)
      if (run[i][j]) {
        for (int k = 1; k < 59; k++)
          if ((j & mask[k]) == 0)
            if (!run[i + 1][j + mask[k]] ||
                dp[i][j] + abs(a[t[i]] - k) < dp[i + 1][j + mask[k]]) {
              run[i + 1][j + mask[k]] = true;
              dp[i + 1][j + mask[k]] = dp[i][j] + abs(a[t[i]] - k);
              from[i + 1][j + mask[k]] = k;
            }
      }
  }
  int pos = -1;
  for (int i = 0; i < (1 << pnum); i++)
    if (run[num][i])
      if (pos == -1 || dp[num][i] < dp[num][pos]) pos = i;
  for (int i = 0; i < n; i++) b[i] = 1;
  int cnt = num;
  while (cnt > 0) {
    b[t[cnt - 1]] = from[cnt][pos];
    pos -= mask[from[cnt][pos]];
    cnt--;
  }
  for (int i = 0; i < n; i++) printf((i) ? " %d" : "%d", b[i]);
  puts("");
}