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;
long long MOD = 1e9 + 7;
void setIO(string name, int submit) {
  if (submit) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  } else {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
}
int dp[101][1 << 18];
void init() {
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 1 << 18; j++) {
      dp[i][j] = 1 << 30;
    }
  }
  dp[0][0] = 0;
}
int s[101];
vector<int> primes;
void sieve() {
  for (int i = 2; i <= 60; i++) {
    if (s[i] == -1) continue;
    s[i] = 1;
    for (int j = 2 * i; j <= 60; j += i) {
      s[j] = -1;
    }
  }
  for (int i = 0; i <= 60; i++) {
    if (s[i] == 1) primes.push_back(i);
  }
}
int main() {
  setIO("", 0);
  init();
  sieve();
  int N;
  cin >> N;
  vector<int> arr;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    arr.push_back(num);
  }
  vector<int> bits;
  for (int num = 2; num <= 60; num++) {
    int temp = num;
    int ct = 0;
    int bit = 0;
    for (int p : primes) {
      while (temp % p == 0) {
        bit |= 1 << ct;
        temp /= p;
      }
      ct++;
    }
    bits.push_back(bit);
  }
  for (int i = 0; i < N; i++) {
    for (int mask = 0; mask < 1 << 16; mask++) {
      dp[i + 1][mask] = min(dp[i + 1][mask], dp[i][mask] + abs(arr[i] - 1));
      for (int num = 2; num <= 60; num++) {
        int bit = bits[num - 2];
        if ((mask & bit) == 0)
          dp[i + 1][mask | bit] =
              min(dp[i + 1][mask | bit], dp[i][mask] + abs(arr[i] - num));
      }
    }
  }
  int bm = 0;
  int best = 1 << 30;
  for (int mask = 0; mask < 1 << 16; mask++) {
    if (dp[N][mask] < best) {
      bm = mask;
      best = dp[N][mask];
    }
  }
  vector<int> ans;
  for (int i = N; i > 0; i--) {
    bool found = false;
    for (int num = 2; num <= 60; num++) {
      int temp = num;
      int ct = 0;
      int bit = 0;
      for (int p : primes) {
        while (temp % p == 0) {
          bit |= 1 << ct;
          temp /= p;
        }
        ct++;
      }
      if ((bm & bit) == bit) {
        if (dp[i - 1][bm ^ bit] + abs(arr[i - 1] - num) == dp[i][bm]) {
          ans.push_back(num);
          bm ^= bit;
          found = true;
          break;
        }
      }
    }
    if (found) continue;
    ans.push_back(1);
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) {
    cout << x << " ";
  }
  return 0;
}