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 N = 110;
const int big = 2e9;
const int md = 1e9 + 7;
int kol, a[N], f[N][(1 << 17)], mask[N], n, aa[N], pr1[N][(1 << 17)],
    pr2[N][(1 << 17)];
bool ok(int x) {
  for (int i = 2; i <= trunc(sqrt(x)); i++)
    if (x % i == 0) return 0;
  return 1;
}
void up(int &x, int y) { x = min(x, y); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> aa[i];
  kol = 0;
  for (int i = 2; i <= 60; i++)
    if (ok(i)) {
      kol++;
      a[kol] = i;
    }
  for (int i = 1; i <= 60; i++) {
    mask[i] = 0;
    for (int j = 1; j <= kol; j++) {
      if (i % a[j] != 0) continue;
      mask[i] += (1 << (j - 1));
    }
  }
  for (int i = 1; i <= n + 1; i++)
    for (int j = 0; j < (1 << kol); j++) f[i][j] = big;
  for (int i = 1; i <= 60; i++)
    if (f[2][mask[i]] > abs(aa[1] - i)) {
      f[2][mask[i]] = abs(aa[1] - i);
      pr2[2][mask[i]] = i;
    }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < (1 << kol); j++) {
      if (f[i][j] == big) continue;
      for (int j1 = 1; j1 <= 60; j1++) {
        if ((mask[j1] & j) != 0) continue;
        if (f[i + 1][j | mask[j1]] > f[i][j] + abs(aa[i] - j1)) {
          f[i + 1][j | mask[j1]] = f[i][j] + abs(aa[i] - j1);
          pr1[i + 1][j | mask[j1]] = j;
          pr2[i + 1][j | mask[j1]] = j1;
        }
      }
    }
  }
  int ans = big;
  for (int i = 0; i < (1 << kol); i++) ans = min(ans, f[n + 1][i]);
  for (int i = 0; i < (1 << kol); i++)
    if (f[n + 1][i] == ans) {
      int t = n + 1;
      int j = i;
      vector<int> v;
      while (t > 1) {
        v.push_back(pr2[t][j]);
        j = pr1[t][j];
        t--;
      }
      for (int j = v.size() - 1; j >= 0; j--) cout << v[j] << " ";
      return 0;
    }
  return 0;
}