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 double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
bool seive[1010000];
vector<int> prime;
void seiveGen(int limit) {
  limit += 100;
  int sqrtn = sqrt(limit);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (!seive[i >> 1]) {
      for (int j = i * i; j < limit; j += i + i) {
        seive[j >> 1] = 1;
      }
    }
  }
  prime.push_back(2);
  for (int i = 3; i < limit; i += 2) {
    if (!seive[i >> 1]) prime.push_back(i);
  }
}
const int mx = 131073;
int dp[123][mx];
int n, a[123], Mask[100];
bool dir[102][131073];
vector<int> fact[100];
void factor() {
  for (int i = 1; i <= 60; i++) {
    int mask = 0;
    for (int j = 0; j < 17; j++) {
      if (i % prime[j] == 0) {
        mask = setBit(mask, j);
      }
    }
    Mask[i] = mask;
  }
}
int solve(int i, int mask) {
  if (i >= n) return 0;
  if (dp[i][mask] != -1) return dp[i][mask];
  long long ret = LLONG_MAX;
  int d;
  int d_tmp = -1;
  for (int j = 1; j <= 60; j++) {
    bool sorry = ((Mask[j] & mask) > 0);
    if (!sorry) {
      int tmp = mask | Mask[j];
      long long ret1 = abs(a[i] - j) + solve(i + 1, tmp);
      if (ret1 < ret) {
        ret = ret1;
        d_tmp = tmp;
        d = j;
      }
    }
  }
  if (d_tmp != -1) dir[i + 1][d_tmp] = 1;
  return dp[i][mask] = ret;
}
void print(int i, int mask) {
  int d_tmp = -1, ret = INT_MAX, d;
  for (int j = 1; j <= 60; j++) {
    bool sorry = ((Mask[j] & mask) > 0);
    if (!sorry) {
      int tmp = mask | Mask[j];
      long long ret1 = abs(a[i] - j) + dp[i + 1][tmp];
      if (ret1 < ret) {
        ret = ret1;
        d_tmp = tmp;
        d = j;
      }
    }
  }
  if (dir[i + 1][d_tmp]) {
    cout << d << " ";
    print(i + 1, d_tmp);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  seiveGen(100);
  factor();
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  solve(0, 0);
  print(0, 0);
  return 0;
}