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 inf = 1e9;
const int N = 1e5 + 1;
const long long mod = 1e9 + 9;
const int bits = 19;
void solve() {
  vector<int> ok(61, 0);
  vector<int> mask(61);
  int ptr = 0;
  for (int i = 2; i <= 60; i++) {
    if (!ok[i]) {
      mask[i] |= (1 << ptr);
      for (int j = 2 * i; j <= 60; j += i) {
        ok[j] = 1;
        mask[j] |= (1 << ptr);
      }
      ptr++;
    }
  }
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<vector<int>> dp(n, vector<int>(1 << ptr + 1, inf)), store;
  store = dp;
  for (int i = 1; i <= 60; i++) {
    if (abs(arr[0] - i) < dp[0][mask[i]]) {
      dp[0][mask[i]] = abs(arr[0] - i);
      store[0][mask[i]] = i;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= (1 << ptr); j++) {
      int val = inf, ele = -1;
      for (int k = 1; k <= 60; k++) {
        if ((j & mask[k]) != mask[k]) continue;
        int omask = j ^ mask[k];
        int nval = min(dp[i - 1][omask] + abs(arr[i] - k), inf);
        if (nval < val) {
          val = nval;
          ele = k;
        }
      }
      dp[i][j] = min(val, inf);
      store[i][j] = ele;
    }
  }
  int smask = -1, val = inf;
  for (int i = 0; i <= (1 << ptr); i++) {
    if (dp[n - 1][i] < val) {
      smask = i;
      val = dp[n - 1][i];
    }
  }
  vector<int> ans;
  while (n--) {
    int ele = store[n][smask];
    smask ^= mask[ele];
    ans.push_back(ele);
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) {
    cout << x << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  std::cout << std::fixed << std::setprecision(20);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}