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 M = 101, N = 1 << 17, K = 60;
int dp[M][N];
int num[M][N];
int p[M][N];
int fact[K];
int primes[17] = {2,  3,  5,  7,  11, 13, 17, 19, 23,
                  29, 31, 37, 41, 43, 47, 53, 59};
void unsetBit(int &n, int p) {
  int temp = 1 << p;
  temp = ~temp;
  n &= temp;
}
void setBit(int &n, int p) {
  int temp = 1 << p;
  n |= temp;
}
template <typename T>
void print_arr(vector<T> &arr) {
  int s = int((arr).size()), i;
  for (i = 0; i < s; i++) cout << arr[i] << ' ';
  cout << '\n';
}
void init() {
  int i, j;
  for (i = 0; i < M; i++)
    for (j = 0; j < N; j++) {
      dp[i][j] = 10000;
      p[i][j] = -1;
    }
  for (i = 1; i < K; i++) {
    int temp = 0;
    for (j = 0; j < 17; j++)
      if (i % primes[j] == 0) setBit(temp, j);
    fact[i] = temp;
  }
}
void solve(vector<int> &a) {
  init();
  int n = int((a).size()), i, j;
  for (i = 1; i < 60; i++) {
    if (dp[0][fact[i]] > abs(i - a[0])) {
      num[0][fact[i]] = i;
      dp[0][fact[i]] = abs(i - a[0]);
    }
  }
  for (i = 1; i < n; i++) {
    for (j = 1; j < 60; j++) {
      int used = fact[j];
      int available = (~used) & ((1 << 17) - 1);
      for (int cur = available;; cur = (cur - 1) & available) {
        if (dp[i - 1][cur] + abs(a[i] - j) < dp[i][cur | used]) {
          dp[i][cur | used] = dp[i - 1][cur] + abs(a[i] - j);
          p[i][cur | used] = cur;
          num[i][cur | used] = j;
        }
        if (cur == 0) break;
      }
    }
  }
  int mn = 10000, ind = -1;
  for (i = 0; i < N; i++) {
    if (mn > dp[n - 1][i]) {
      mn = dp[n - 1][i];
      ind = i;
    }
  }
  vector<int> b(n);
  b[n - 1] = num[n - 1][ind];
  for (i = n - 2; i >= 0; i--) {
    ind = p[i + 1][ind];
    b[i] = num[i][ind];
  }
  for (i = 0; i < n; i++) cout << b[i] << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  ;
  vector<int> arr(n);
  int i, j;
  for (i = 0; i < n; i++) cin >> arr[i];
  solve(arr);
}