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 xx[4] = {0, 0, 1, -1};
int yy[4] = {1, -1, 0, 0};
int n;
int a[int(1e2 + 10)];
int f[int(1e2 + 10)][((1 << 17) - 1) + 10];
pair<int, int> trace[int(1e2 + 10)][((1 << 17) - 1) + 10];
bool fr[int(1e2 + 10)];
int dem;
int x[int(1e2 + 10)], t[int(1e2 + 10)], c[int(1e2 + 10)], fact[int(1e2 + 10)];
int biton(int x, int i) { return x | (1 << i); }
int main() {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; i++) scanf("%d", &a[i]);
  memset(f, 63, sizeof(f));
  int def = f[0][0];
  memset(fr, true, sizeof(fr));
  for (int i = (2), _b = (60); i <= _b; i++)
    if (fr[i]) {
      dem++;
      x[dem - 1] = i;
      t[i] = dem - 1;
      for (int j = (1), _b = (60 / i); j <= _b; j++) {
        c[i * j] = i;
        fr[i * j] = false;
      }
    }
  for (int i = (2), _b = (60); i <= _b; i++) {
    fact[i] = biton(fact[i / c[i]], t[c[i]]);
  }
  f[0][0] = 0;
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int x = (1), _b = (60); x <= _b; x++) {
      int ss = ((1 << 17) - 1) & (~fact[x]);
      for (int s = ss;; s = (s - 1) & ss) {
        int s2 = s | fact[x];
        if (f[i][s2] > f[i - 1][s] + abs(a[i] - x)) {
          f[i][s2] = f[i - 1][s] + abs(a[i] - x);
          trace[i][s2].first = s;
          trace[i][s2].second = x;
        }
        if (s == 0) break;
      }
    }
  }
  int v = 0;
  int res = def;
  for (int s = (0), _b = (((1 << 17) - 1)); s <= _b; s++)
    if (f[n][s] < res) {
      res = f[n][s];
      v = s;
    }
  int r[int(1e2 + 10)];
  for (int i = (n), _a = (1); i >= _a; i--) {
    r[i] = trace[i][v].second;
    v = trace[i][v].first;
  }
  for (int i = (1), _b = (n); i <= _b; i++) printf("%d ", r[i]);
}