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 maxn = 100;
const int maxs = 1 << 17;
const int INF = 1 << 29;
int n;
int a[maxn + 10];
int m[maxn + 10];
int f[maxn + 10][maxs + 10];
int plan[maxn + 10][maxs + 10];
int las[maxn + 10][maxs + 10];
int p[maxn + 10], pn;
int b[maxn + 10], bn;
int Calc(int x, int pr) {
  int ret = pr, t = pr * pr;
  while ((((x - t) < 0) ? (-(x - t)) : (x - t)) <
         (((x - ret) < 0) ? (-(x - ret)) : (x - ret))) {
    ret = t;
    t *= pr;
  }
  return ret;
}
int main() {
  for (int i = 2; i <= 60; ++i) {
    p[pn++] = i;
    for (int j = 2; j * j <= i; ++j)
      if (i % j == 0) {
        --pn;
        break;
      }
  }
  for (int i = 1; i <= 60; ++i)
    for (int j = 0; j < pn; ++j)
      if (i % p[j] == 0) m[i] |= (1 << j);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int lim = 1 << pn, x, t, cost;
  for (int i = 1; i <= n; ++i) {
    for (int s = 0; s < lim; ++s) {
      f[i][s] = INF;
      for (int j = 1; j <= 59; ++j)
        if ((s & m[j]) == m[j]) {
          t = s - m[j];
          cost = (((j - a[i]) < 0) ? (-(j - a[i])) : (j - a[i]));
          if (f[i - 1][t] + cost < f[i][s]) {
            plan[i][s] = j;
            las[i][s] = t;
            f[i][s] = f[i - 1][t] + cost;
          }
        }
    }
  }
  int ans = INF, s = -1;
  for (int i = 0; i < lim; ++i)
    if (f[n][i] < ans) ans = f[n][i], s = i;
  for (int i = n; i >= 1; --i) {
    b[bn++] = plan[i][s];
    s = las[i][s];
  }
  for (int i = bn - 1; i >= 0; --i) printf("%d ", b[i]);
  return 0;
}