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 dp[105][140050], n, a[150],
    zs[17] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53},
    fa[105][140050], ztt[60];
vector<int> zyz[60];
void Read(int &x) {
  x = 0;
  int p = 0;
  char st = getchar();
  while (st < '0' || st > '9') p = (st == '-'), st = getchar();
  while (st >= '0' && st <= '9')
    x = (x << 1) + (x << 3) + st - '0', st = getchar();
  x = p ? -x : x;
  return;
}
void Prework() {
  for (int i = 1; i <= 58; i++)
    for (int j = 0; zs[j] <= i && j < 16; j++)
      if (i % zs[j] == 0) ztt[i] |= (1 << j);
  return;
}
int Abs(int x) { return x < 0 ? -x : x; }
void Print(int pos, int zt) {
  if (pos == 0) return;
  Print(pos - 1, zt ^ ztt[fa[pos][zt]]);
  printf("%d ", fa[pos][zt]);
  return;
}
int main() {
  Prework();
  Read(n);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 16); j++) dp[i][j] = 0x7f7f7f7f;
  for (int i = 1; i <= n; i++) Read(a[i]);
  for (int i = 1; i <= 58; i++) {
    if (Abs(a[1] - i) < dp[1][ztt[i]]) {
      dp[1][ztt[i]] = Abs(a[1] - i);
      fa[1][ztt[i]] = i;
    }
  }
  for (int i = 2; i <= n; i++)
    for (int zt = 0; zt < (1 << 16); zt++)
      if (dp[i - 1][zt] != 0x7f7f7f7f)
        for (int j = 1; j <= 58; j++)
          if (!(ztt[j] & zt)) {
            if (dp[i - 1][zt] + Abs(a[i] - j) < dp[i][zt | ztt[j]]) {
              fa[i][zt | ztt[j]] = j;
              dp[i][zt | ztt[j]] = dp[i - 1][zt] + Abs(a[i] - j);
            }
          }
  int zt, ans = 0x7f7f7f7f;
  for (int i = 0; i < (1 << 16); i++)
    if (dp[n][i] < ans) ans = dp[n][i], zt = i;
  Print(n, zt);
  return 0;
}