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;
int a[200];
int dp[105][200000];
int prim[30];
int f[100];
int cnt;
int ri[200000];
void pre() {
  memset(f, 0, sizeof(f));
  cnt = 1;
  prim[0] = 2;
  f[2] = 1;
  for (int i = 3; i < 60; i++) {
    bool flag = 1;
    for (int j = 0; j < cnt; j++)
      if (i % prim[j] == 0) {
        flag = 0;
        break;
      }
    if (flag) {
      f[i] = (1 << cnt);
      prim[cnt++] = i;
    }
  }
  for (int i = 2; i < 60; i++) {
    for (int j = 0; prim[j] < i; j++)
      if (i % prim[j] == 0) {
        f[i] += f[prim[j]];
      }
  }
}
int main() {
  pre();
  while (~scanf("%d", &n)) {
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (int j = 1; j < 60; j++)
      if (dp[0][f[j]] == -1 || dp[0][f[j]] > abs(a[0] - j)) {
        dp[0][f[j]] = abs(a[0] - j);
        ri[f[j]] = j;
      }
    for (int i = 1; i < n; i++) {
      for (int p = 0; p < (1 << cnt); p++)
        if (dp[i - 1][p] != -1) {
          for (int j = 1; j < 60; j++)
            if ((p & f[j]) == 0) {
              if (dp[i][p | f[j]] == -1)
                dp[i][p | f[j]] = dp[i - 1][p] + abs(j - a[i]);
              else
                dp[i][p | f[j]] =
                    min(dp[i][p | f[j]], dp[i - 1][p] + abs(j - a[i]));
            }
        }
    }
    int res = 30 * 100;
    int yy;
    for (int p = 0; p < (1 << cnt); p++)
      if (dp[n - 1][p] != -1 && dp[n - 1][p] < res) {
        res = dp[n - 1][p];
        yy = p;
      }
    int ans[200];
    for (int i = n - 1; i > 0; i--) {
      for (int j = 1; j < 60; j++)
        if ((f[j] & yy) == f[j] && dp[i - 1][yy - f[j]] != -1)
          if (dp[i - 1][yy - f[j]] + abs(a[i] - j) == dp[i][yy]) {
            ans[i] = j;
            yy = yy - f[j];
            break;
          }
    }
    ans[0] = ri[yy];
    for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
    cout << ans[n - 1] << endl;
  }
  return 0;
}