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 arr[110];
int ord[110];
bool p[60][60];
bool cmp(const int &a, const int &b) { return (arr[a] < arr[b]); }
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int ans[110];
int cur[110];
int bval;
int used[60];
void eval(int an) {
  int cval = 0;
  for (int i = 0; i < n - an; i++) cval += abs(1 - arr[ord[i]]);
  for (int i = n - an; i < n; i++) cval += abs(arr[ord[i]] - cur[i - n + an]);
  if (cval < bval) {
    bval = cval;
    for (int i = 0; i < n - an; i++) ans[ord[i]] = 1;
    for (int i = n - an; i < n; i++) ans[ord[i]] = cur[i - n + an];
  }
}
void go(int id, int rid, int st) {
  if (id == n) {
  } else {
    for (int t = st; t < 60; t++) {
      if (used[t] == 1) continue;
      bool OK = true;
      for (int j = 2; j < 60 && OK; j++)
        if (used[j] == 1 && p[t][j] == false) OK = false;
      if (OK) {
        used[t] = 1;
        cur[rid] = t;
        eval(rid + 1);
        go(id + 1, rid + 1, t + 1);
        used[t] = 0;
      }
    }
  }
}
int main(void) {
  for (int a = 1; a < 60; a++)
    for (int b = 1; b < 60; b++) p[a][b] = (gcd(a, b) == 1);
  for (;;) {
    cin >> n;
    if (cin.eof()) break;
    bval = 0;
    memset(used, 0, sizeof(used));
    for (int i = 0; i < n; i++) {
      ord[i] = i;
      cur[i] = ans[i] = 1;
      cin >> arr[i];
      bval += abs(ans[i] - arr[i]);
    }
    sort(ord, ord + n, cmp);
    go(max(n - 17, 0), 0, 2);
    cout << ans[0];
    for (int i = 1; i < n; i++) cout << " " << ans[i];
    cout << endl;
  }
  return 0;
}