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 long long int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
void solve() {
  long long int n, a;
  cin >> n;
  vector<long long int> v;
  for (long long int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  vector<long long int> primes = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                                  29, 31, 37, 41, 43, 47, 53, 59};
  vector<vector<long long int>> fac(62);
  for (long long int i = 0; i < (long long int)(primes.size()); i++) {
    for (long long int j = 1; j < 60; j++) {
      if (j % primes[i] == 0) {
        fac[j].push_back(primes[i]);
      }
    }
  }
  map<long long int, long long int> mp;
  for (long long int i = 0; i < (long long int)(primes.size()); i++) {
    mp[primes[i]] = i;
  }
  long long int lim = (1ll << 17);
  vector<vector<long long int>> dp(n + 2, vector<long long int>(lim + 2, 1e10));
  for (long long int no = 1; no < 60; no++) {
    long long int val = abs(no - v[0]);
    long long int bits = 0;
    for (long long int j = 0; j < fac[no].size(); j++) {
      long long int p = mp[fac[no][j]];
      long long int q = (1ll << p);
      bits += q;
    }
    dp[0][bits] = min(dp[0][bits], val);
  }
  for (long long int i = 1; i < n; i++) {
    for (long long int no = 1; no < 60; no++) {
      long long int val = abs(no - v[i]);
      long long int bits = 0;
      for (long long int j = 0; j < fac[no].size(); j++) {
        long long int p = mp[fac[no][j]];
        long long int q = (1ll << p);
        bits += q;
      }
      for (long long int mask = 0; mask < lim; mask++) {
        if ((mask & bits) == 0) {
          long long int new_mask = (mask | bits);
          dp[i][new_mask] = min(dp[i][new_mask], dp[i - 1][mask] + val);
        }
      }
    }
  }
  long long int ans = 1e10;
  long long int store_mask;
  for (long long int mask = 0; mask < lim; mask++) {
    if (dp[n - 1][mask] < ans) {
      store_mask = mask;
    }
    ans = min(ans, dp[n - 1][mask]);
  }
  vector<long long int> store_ans;
  for (long long int i = n - 1; i > 0; i--) {
    for (long long int no = 1; no < 60; no++) {
      long long int val = abs(no - v[i]);
      long long int bits = 0;
      for (long long int j = 0; j < fac[no].size(); j++) {
        long long int p = mp[fac[no][j]];
        long long int q = (1ll << p);
        bits += q;
      }
      long long int req = ans - val;
      long long int p = (store_mask & bits);
      if (p != bits) {
        continue;
      }
      long long int new_mask = (store_mask ^ bits);
      if (dp[i - 1][new_mask] == req) {
        store_ans.push_back(no);
        ans -= val;
        store_mask = new_mask;
        break;
      }
    }
  }
  long long int last;
  for (long long int no = 59; no >= 1; no--) {
    long long int bits = 0;
    long long int valu = abs(v[0] - no);
    for (long long int j = 0; j < fac[no].size(); j++) {
      long long int p = mp[fac[no][j]];
      long long int q = (1ll << p);
      bits += q;
    }
    long long int p = (store_mask & bits);
    if (p != bits) {
      continue;
    } else {
      if (valu == ans) {
        last = no;
        break;
      }
    }
  }
  store_ans.push_back(last);
  reverse(store_ans.begin(), store_ans.end());
  for (long long int i = 0; i < n; i++) {
    cout << store_ans[i] << " ";
  }
  cout << endl;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}