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;
bool vis[60];
vector<int> primes, v, ar[66];
int dp[105][(1 << 16) + 5];
int fact[105];
void sieve() {
  memset(vis, true, sizeof(vis));
  for (int i = 2; i <= 53; i++) {
    if (vis[i] == true) {
      for (int j = 2 * i; j <= 53; j += i) vis[j] = false;
      primes.push_back(i);
    }
  }
}
bool Check(int n, int pos) { return n & (1 << pos); }
int Set(int n, int pos) { return n | (1 << pos); }
int f(int i, int mask) {
  if (i == v.size()) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  int value = 1e7;
  for (int j = 1; j <= 53; j++) {
    int fac = j, now = mask;
    bool possible = true;
    for (int i1 = 0; i1 < ar[j].size(); i1++) {
      if (Check(now, ar[j][i1]) == true) {
        possible = false;
        break;
      }
      now = Set(now, ar[j][i1]);
    }
    if (possible == true) value = min(value, f(i + 1, now) + abs(v[i] - j));
  }
  return dp[i][mask] = value;
}
void pre() {
  for (int i = 2; i <= 53; i++) {
    int temp = i;
    for (int j = 0; primes[j] * primes[j] <= temp; j++) {
      if (temp % primes[j] == 0) {
        while (temp % primes[j] == 0) {
          temp /= primes[j];
        }
        ar[i].push_back(j);
      }
    }
    if (temp > 1) {
      for (int j = 0; j < primes.size(); j++) {
        if (primes[j] == temp) ar[i].push_back(j);
      }
    }
  }
}
int main(void) {
  sieve();
  int n;
  scanf("%d", &n);
  vector<int> temp(n);
  set<int> st;
  for (int i = 0; i < n; i++) {
    scanf("%d", &temp[i]);
    v.push_back(temp[i]);
  }
  pre();
  memset(dp, -1, sizeof(dp));
  int ans = f(0, 0), mask = 0, pre = 0;
  for (int i = 0; i < v.size(); i++) {
    int now = mask, val = 0;
    for (int j = 1; j <= 53; j++) {
      int fac = j;
      now = mask;
      bool possible = true;
      for (int k = 0; primes[k] * primes[k] <= fac; k++) {
        if (fac % primes[k] == 0) {
          while (fac % primes[k] == 0) {
            fac /= primes[k];
          }
          if (Check(now, k) == true) {
            possible = false;
            break;
          } else
            now = Set(now, k);
        }
      }
      if (possible == false) continue;
      if (fac > 1) {
        for (int i1 = 0; i1 < primes.size(); i1++) {
          if (primes[i1] == fac) {
            if (Check(now, i1) == true) possible = false;
            now = Set(now, i1);
          }
        }
      }
      if (possible == false) continue;
      val = f(i + 1, now);
      if (pre + val + abs(v[i] - j) == ans) {
        mask = now;
        pre += abs(v[i] - j);
        temp[i] = j;
        break;
      }
    }
  }
  for (auto it : temp) cout << it << " ";
  return 0;
}