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;
int fact[60];
int dp[131072][100];
int arr[100];
int ans[100];
int abs(int x) {
  if (x > 0) return x;
  return -x;
}
bool match(int a, int b) {
  while (b > 0) {
    int num = (b & (-b));
    if ((a & num) == 0) return 0;
    b -= num;
  }
  return 1;
}
int main() {
  int p = 0;
  for (int i = 2; i < 60; i++) {
    if (fact[i] == 0) {
      int j = i;
      while (j < 60) {
        fact[j] += (1 << p);
        j += i;
      }
      p++;
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  dp[0][0] = abs(arr[0] - 1);
  for (int j = 1; j < n; j++) dp[0][j] = abs(arr[j] - 1) + dp[0][j - 1];
  for (int i = 1; i < 131072; i++) {
    dp[i][0] = abs(arr[0] - 1);
    for (int k = 2; k < 60; k++)
      if (match(i, fact[k])) dp[i][0] = min(dp[i][0], abs(arr[0] - k));
    for (int j = 1; j < n; j++) {
      dp[i][j] = abs(arr[j] - 1) + dp[i][j - 1];
      for (int k = 2; k < 60; k++)
        if (match(i, fact[k]))
          dp[i][j] = min(dp[i][j], abs(arr[j] - k) + dp[i - fact[k]][j - 1]);
    }
  }
  int num = 131071;
  for (int i = n - 1; i > 0; i--) {
    if (dp[num][i] == dp[num][i - 1] + abs(arr[i] - 1))
      ans[i] = 1;
    else {
      for (int k = 2; k < 60; k++) {
        if (match(num, fact[k]) &&
            dp[num][i] == dp[num - fact[k]][i - 1] + abs(k - arr[i])) {
          ans[i] = k;
          num -= fact[k];
          break;
        }
      }
    }
  }
  if (dp[num][0] != abs(arr[0] - 1)) {
    for (int k = 2; k < 60; k++) {
      if (match(num, fact[k]) && dp[num][0] == abs(k - arr[0])) {
        ans[0] = k;
        break;
      }
    }
  } else
    ans[0] = 1;
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}