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 INF = 3000;
void localFile() {
  freopen("cf.in", "r", stdin);
  freopen("cf.out", "w", stdout);
}
vector<int> primes;
int bitmatch[60], patterns[60];
bool sieve[60];
int p = 16;
vector<int> poss[1 << 16];
int n, a[101], d[101][1 << 16], b[101][1 << 16];
int main(void) {
  for (int i = 2; i < 59; i++) {
    if (sieve[i] == false) {
      primes.push_back(i);
      for (int j = i + i; j < 59; j += i) {
        sieve[j] = true;
      }
    }
  }
  for (int i = 0; i < (int)primes.size(); i++) {
    bitmatch[primes[i]] = i;
  }
  for (int num = 2; num < 59; num++) {
    int pattern = 0;
    for (int j = 0; j < p; j++) {
      int prime = primes[j];
      if (num % prime == 0) {
        pattern |= (1 << j);
      }
    }
    patterns[num] = pattern;
  }
  for (int i = 0; i < (1 << p); i++) {
    for (int j = 2; j < 59; j++) {
      if ((i & patterns[j]) == patterns[j]) {
        poss[i].push_back(j);
      }
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << p); j++) {
      d[i][j] = INF;
      b[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < (1 << p); j++) {
      d[i][j] = min(d[i][j], d[i - 1][j] + abs(a[i] - 1));
      b[i][j] = -1;
      for (int id = 0; id < (int)poss[j].size(); id++) {
        int num = poss[j][id];
        int pat = patterns[num];
        int jp = j - pat;
        if (d[i][j] > d[i - 1][jp] + abs(a[i] - num)) {
          d[i][j] = d[i - 1][jp] + abs(a[i] - num);
          b[i][j] = id;
        }
      }
    }
  }
  int minval = INF, st = -1;
  vector<int> ans;
  for (int j = 0; j < (1 << p); j++) {
    if (d[n][j] < minval) {
      minval = d[n][j];
      st = j;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (b[i][st] == -1) {
      ans.push_back(1);
    } else {
      ans.push_back(poss[st][b[i][st]]);
      st -= patterns[poss[st][b[i][st]]];
    }
  }
  for (int i = (int)ans.size() - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}