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 a[110];
int F[65];
int C[65];
int dp[101][150000];
int path[101][150000];
int path2[101][150000];
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
vector<int> v;
void buildPrime() {
  int i, j, k, l;
  int all = (1 << 17) - 1;
  for (int n = 2; n <= 60; n++) {
    k = 0;
    for (i = 0; i < 17; i++) {
      if (n % prime[i] == 0) k |= 1 << i;
    }
    F[n] = k;
    C[n] = all ^ k;
  }
  C[1] = all;
}
int main() {
  int n, i, j, k, l;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  buildPrime();
  for (i = 0; i <= 100; i++) {
    for (j = 0; j < 150000; j++) {
      dp[i][j] = 3000;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 1; j < a[i] * 2; j++) {
      for (k = C[j];; k = (k - 1) & C[j]) {
        if (j > 1) {
          if (i - 1 >= 0) {
            if (dp[i][k | F[j]] > dp[i - 1][k] + abs(a[i] - j)) {
              dp[i][k | F[j]] =
                  min(dp[i][k | F[j]], dp[i - 1][k] + abs(a[i] - j));
              path[i][k | F[j]] = k;
              path2[i][k | F[j]] = j;
            }
          } else {
            dp[i][F[j]] = abs(a[i] - j);
            path[i][F[j]] = -1;
            path2[i][F[j]] = j;
          }
          if (k == 0) break;
        } else {
          if (i - 1 >= 0) {
            if (dp[i][k] > dp[i - 1][k] + abs(a[i] - j)) {
              dp[i][k] = min(dp[i][k], dp[i - 1][k] + abs(a[i] - j));
              path[i][k] = k;
              path2[i][k] = j;
            }
          } else {
            if (dp[i][0] > abs(a[i] - j)) {
              dp[i][0] = abs(a[i] - j);
              path[i][0] = -1;
              path2[i][0] = j;
            }
          }
          if (k == 0) break;
        }
      }
    }
  }
  int ans = 3000;
  int x;
  for (i = 0; i < 140000; i++) {
    if (ans > dp[n - 1][i]) {
      ans = dp[n - 1][i];
      x = i;
    }
  }
  for (i = n - 1, j = x; i >= 0; i--) {
    k = path[i][j];
    l = path2[i][j];
    v.push_back(l);
    j = k;
  }
  for (i = v.size() - 1; i >= 0; i--) {
    cout << v[i] << ' ';
  }
}