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 cnt = 0, n, a[105];
int prime[50];
int S = 1 << 16;
int s[65];
int pre[105][1 << 18];
int dp[105][1 << 18];
inline void prepare() {
  prime[0] = 2;
  for (int i = 3; i <= 60; i++) {
    bool flag = false;
    for (int j = 2; j * j <= i; j++)
      if (i % j == 0) {
        flag = true;
        break;
      }
    if (!flag) prime[++cnt] = i;
  }
  for (int i = 1; i < 60; i++) {
    int u = i;
    for (int j = 0; j <= cnt; j++) {
      while (u % prime[j] == 0) {
        u /= prime[j];
        s[i] |= (1 << j);
      }
    }
  }
}
int num[105];
inline void print(int ss, int pos) {
  if (ss == 1) return;
  num[ss] = pre[ss][pos];
  print(ss - 1, pos ^ s[num[ss]]);
}
inline void work() {
  memset(pre, -1, sizeof(pre));
  pre[1][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << 16); j++) {
      if (pre[i][j] == -1) continue;
      for (int k = 1; k < 60; k++) {
        if (j & s[k]) continue;
        int next = j | s[k];
        if (pre[i + 1][next] == -1 ||
            dp[i][j] + abs(a[i] - k) < dp[i + 1][next]) {
          pre[i + 1][next] = k;
          dp[i + 1][next] = dp[i][j] + abs(a[i] - k);
        }
      }
    }
  }
  int ans = 1 << 30;
  int pos = 0;
  for (int i = 0; i < 1 << 16; i++) {
    if (dp[n + 1][i] < ans && pre[n + 1][i] != -1) {
      ans = dp[n + 1][i];
      pos = i;
    }
  }
  print(n + 1, pos);
  for (int i = 2; i <= n + 1; i++) cout << num[i] << " ";
  cout << endl;
}
int main() {
  prepare();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  work();
  return 0;
}