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;
int l(int q) {
  if (q < 0) q = -q;
  return q;
}
int main() {
  int q, w, e, r, t = 0, c, s[30], *d[101], *d1[101], *f[65536], *f2[65536],
                  f1[65536], g[100], g1[100], h[59];
  bool a[60];
  for (w = 0; w < 59; w++) a[w] = 1;
  for (w = 2; w < 60; w++)
    if (a[w]) {
      s[t] = w;
      t++;
      for (e = w * 2; e < 60; e += w) a[e] = 0;
    }
  for (w = 1; w < 59; w++) {
    h[w] = 0;
    for (e = 0, r = 1; e < t; e++, r <<= 1)
      if (w % s[e] == 0) h[w] += r;
  }
  bool b;
  d[0] = new int[65536];
  for (w = 0; w < 65536; w++) {
    d[0][w] = 100000;
    f1[w] = 0;
    for (e = 1; e < 59; e++) {
      if ((w & h[e]) == 0) {
        g[f1[w]] = e;
        g1[f1[w]] = w | h[e];
        f1[w]++;
      }
    }
    f[w] = new int[f1[w]];
    f2[w] = new int[f1[w]];
    for (e = 0; e < f1[w]; e++) {
      f[w][e] = g[e];
      f2[w][e] = g1[e];
    }
  }
  scanf("%d", &q);
  d[0][0] = 0;
  for (c = 0; c < q; c++) {
    scanf("%d", &r);
    d[c + 1] = new int[65536];
    d1[c + 1] = new int[65536];
    for (w = 0; w < 65536; w++) d[c + 1][w] = 100000;
    for (w = 0; w < 65536; w++)
      for (e = 0; e < f1[w]; e++)
        if (d[c][w] + l(r - f[w][e]) < d[c + 1][f2[w][e]]) {
          d[c + 1][f2[w][e]] = d[c][w] + l(r - f[w][e]);
          d1[c + 1][f2[w][e]] = f[w][e];
        }
  }
  c = 0;
  for (w = 1; w < 65536; w++)
    if (d[q][c] > d[q][w]) c = w;
  for (w = q; w; w--) {
    g[w] = d1[w][c];
    c -= h[g[w]];
  }
  for (w = 1; w <= q; w++) printf("%d ", g[w]);
  return 0;
}