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 MAX = 17;
const int N = 102;
const int MAXBi = 60;
int memo[N][1 << MAX];
int a[N];
int n;
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
vector<int> primeFactors[MAXBi];
int dp(int i, int mask) {
  if (i == n) {
    return 0;
  }
  int &ret = memo[i][mask];
  if (ret != -1) return ret;
  ret = dp(i + 1, mask) + (a[i] - 1);
  for (int j = 2; j < a[i] << 1; j++) {
    bool ok = true;
    int newMask = mask;
    for (int k = 0; k < (int)primeFactors[j].size(); k++) {
      int p = primeFactors[j][k];
      if ((mask >> p) & 1) {
        ok = false;
        break;
      }
      newMask |= (1 << p);
    }
    if (ok) {
      ret = min(ret, dp(i + 1, newMask) + abs(j - a[i]));
    }
  }
  return ret;
}
void generatePrimeFactors() {
  for (int i = 2; i < MAXBi; i++) {
    int num = i;
    for (int j = 0; j < MAX; j++) {
      while (num % primes[j] == 0) {
        primeFactors[i].push_back(j);
        num /= primes[j];
      }
    }
  }
}
void print(int i, int mask) {
  if (i == n) return;
  int num = -1;
  int newMask;
  for (int j = 2; j < a[i] << 1; j++) {
    newMask = mask;
    bool ok = true;
    for (int k = 0; k < (int)primeFactors[j].size(); k++) {
      int p = primeFactors[j][k];
      if (((mask >> p) & 1)) {
        ok = false;
        break;
      }
      newMask |= (1 << p);
    }
    if (ok && dp(i, mask) == dp(i + 1, newMask) + abs(j - a[i])) {
      num = j;
      break;
    }
  }
  if (num == -1) {
    printf("1 ");
    print(i + 1, mask);
  } else {
    printf("%d ", num);
    print(i + 1, newMask);
  }
}
int main() {
  generatePrimeFactors();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  memset(memo, -1, sizeof memo);
  int temp = dp(0, 0);
  print(0, 0);
  return 0;
}