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 n;
int a[109];
int dp[109][131079];
int truyvet[109][131079][3];
int mang[69];
int d[30] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int pow(int a, int b) {
  int o = 1 << b;
  return o;
}
void taomang() {
  for (int i = 1; i <= 60; i++) {
    int b = 0;
    for (int j = 1; j <= 17; j++) {
      if (i % d[j] == 0) {
        b = (b | 1 << (j - 1));
      }
    }
    mang[i] = b;
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  taomang();
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= pow(2, 17) - 1; j++) {
      if (dp[i - 1][j] != -1) {
        for (int t = 1; t <= 60; t++) {
          int k = j & mang[t];
          if (k == 0) {
            if (dp[i][j ^ mang[t]] == -1 ||
                dp[i][j ^ mang[t]] > dp[i - 1][j] + abs(a[i] - t)) {
              dp[i][j ^ mang[t]] = dp[i - 1][j] + abs(a[i] - t);
              truyvet[i][j ^ mang[t]][1] = t;
              truyvet[i][j ^ mang[t]][2] = j;
            }
          }
        }
      }
    }
  }
  int sum = 0;
  int mi = dp[n][0];
  for (int j = 1; j <= pow(2, 17) - 1; j++) {
    if (dp[n][j] == -1) continue;
    if (min(mi, dp[n][j]) == dp[n][j]) {
      sum = j;
      mi = dp[n][j];
    }
  }
  int kq[109];
  int dem = 1;
  for (int i = n; i >= 1; i--) {
    kq[dem] = truyvet[i][sum][1];
    dem++;
    sum = truyvet[i][sum][2];
  }
  for (int i = dem - 1; i >= 1; i--) {
    cout << kq[i] << ' ';
  }
  cout << endl;
  return 0;
}