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 N, ans, INF;
int at[105];
int p[105], a[105];
int pr[65] = {0,  2,  3,  5,  7,  11, 13, 17, 19, 23,
              29, 31, 37, 41, 43, 47, 53, 59, 61};
int dp[105][1024][8];
int last[105][1024][8][3];
int cmp(int x, int y) { return a[x] < a[y]; }
void Update(int ii, int jj, int tt, int i, int j, int t, int s) {
  int tmp = dp[i][j][t] + abs(s - a[ii]);
  if (dp[ii][jj][tt] <= tmp) return;
  dp[ii][jj][tt] = tmp;
  last[ii][jj][tt][0] = j;
  last[ii][jj][tt][1] = t;
  last[ii][jj][tt][2] = s;
}
int main() {
  int i, j, t, s, k;
  int ii, jj, tt;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    at[i] = i;
  }
  sort(at + 1, at + 1 + N, cmp);
  sort(a + 1, a + 1 + N);
  memset(dp, 63, sizeof(dp));
  INF = dp[0][0][0], dp[0][0][0] = 0;
  for (i = 0; i < N; i++)
    for (j = 0; j < 1024; j++)
      for (t = 0; t < 8; t++)
        if (dp[i][j][t] != INF)
          for (s = 1; s <= 60; s++) {
            jj = j, tt = t;
            for (k = 1; k <= 17; k++)
              if (s % pr[k] == 0) {
                if (k <= 10)
                  if (((j >> k - 1) & 1))
                    break;
                  else
                    jj = (jj | (1 << k - 1));
                else if (s != pr[t + 11])
                  break;
                else
                  tt++;
              }
            if (k <= 17) continue;
            Update(i + 1, jj, tt, i, j, t, s);
          }
  ans = INF;
  for (j = 0; j < 1024; j++)
    for (t = 0; t < 8; t++)
      if (dp[N][j][t] < ans) {
        ans = dp[N][j][t];
        jj = j, tt = t;
      }
  for (i = N; i > 0; i--) {
    p[at[i]] = last[i][jj][tt][2];
    j = jj;
    jj = last[i][jj][tt][0];
    tt = last[i][j][tt][1];
  }
  for (i = 1; i <= N; i++) printf("%d ", p[i]);
  return 0;
}