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];
vector<int> primes;
void ReadData() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
}
int fact[69];
int dp[109][(1 << 17) + 9];
pair<int, int> dp2[109][(1 << 17) + 9];
void Solve() {
  memset(dp, 0x7F, sizeof(dp));
  memset(dp, 0, sizeof(int) * ((1 << 17) + 9));
  for (int i = 0; i < 109; i++) {
    for (int j = 0; j < (1 << 17) + 9; j++) {
      dp2[i][j].first = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int k = 1; k < 60; k++) {
      int X = (~fact[k]) & ((1 << 17) - 1);
      for (int s = X;; s = (s - 1) & X) {
        if (abs(a[i - 1] - k) + dp[i - 1][s] < dp[i][s | fact[k]]) {
          dp[i][s | fact[k]] = abs(a[i - 1] - k) + dp[i - 1][s];
          dp2[i][s | fact[k]].first = k;
          dp2[i][s | fact[k]].second = s;
        }
        if (s == 0) {
          break;
        }
      }
    }
  }
}
void g(int mask, int idx) {
  if (idx == 0) {
    return;
  }
  g(dp2[idx][mask].second, idx - 1);
  printf("%d ", dp2[idx][mask].first);
}
void WriteData() {
  int mask;
  int minimal = INT_MAX;
  for (int i = 0; i < (1 << 17) + 9; i++) {
    if (dp[n][i] < minimal) {
      mask = i;
      minimal = dp[n][i];
    }
  }
  g(mask, n);
  printf("\n");
}
int main() {
  primes.push_back(2);
  for (int i = 3; i < 60; i++) {
    bool flag = true;
    for (int j = 2; j < i; j++) {
      if ((i % j) == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      primes.push_back(i);
    }
  }
  memset(fact, 0, sizeof(fact));
  int primesCnt = primes.size();
  for (int i = 2; i < 60; i++) {
    for (int j = 0; j < primesCnt; j++) {
      if ((i % primes[j]) == 0) {
        fact[i] |= 1 << j;
      }
    }
  }
  int QWE = 1;
  for (int T = 0; T < QWE; T++) {
    ReadData();
    Solve();
    WriteData();
  }
  return 0;
}