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 siz = 1e2 + 10;
const int mod = 1e9 + 7;
const int MAXX = 1e18;
int n;
vector<int> hold;
int res[siz][(1 << 17)];
bool check[siz];
int pos[siz];
void sieve() {
  for (int i = 2; i * i <= 60; i++) {
    if (check[i]) {
      for (int j = i * i; j <= 60; j += i) {
        check[j] = false;
      }
    }
  }
  int cnt = 0;
  for (int i = 2; i <= 60; i++) {
    if (check[i]) {
      pos[i] = cnt++;
    }
  }
}
int pres[siz];
int creNum(int num) {
  int x = 0;
  for (int i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      x |= (1 << pos[i]);
      while (num % i == 0) {
        num /= i;
      }
    }
  }
  if (num != 1) {
    x |= (1 << pos[num]);
  }
  return x;
}
void setup() {
  for (int i = 2; i <= 60; i++) {
    pres[i] = creNum(i);
  }
}
int dp(int cur, int mask) {
  if (cur >= n) {
    return res[cur][mask] = 0;
  }
  if (res[cur][mask] != -1) {
    return res[cur][mask];
  }
  int ans = MAXX;
  for (int i = 2; i <= 60; i++) {
    if ((mask & pres[i]) == 0) {
      ans = min(ans, dp(cur + 1, mask | pres[i]) + abs(hold[cur] - i));
    }
  }
  ans = min(ans, dp(cur + 1, mask) + abs(hold[cur] - 1));
  return res[cur][mask] = ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  hold.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> hold[i];
  }
  memset(check, true, sizeof(check));
  sieve();
  setup();
  memset(res, -1, sizeof(res));
  int ans = dp(0, 0);
  int mask = 0;
  for (int i = 0; i < n; i++) {
    if ((res[i][mask] - abs(hold[i] - 1)) == res[i + 1][mask]) {
      cout << 1 << ' ';
      ans -= abs(hold[i] - 1);
      continue;
    }
    for (int j = 2; j <= 60; j++) {
      if ((mask & (pres[j])) == 0) {
        if ((res[i][mask] - abs(hold[i] - j)) == res[i + 1][mask | pres[j]]) {
          cout << j << ' ';
          mask |= pres[j];
          ans -= abs(hold[i] - j);
          break;
        }
      }
    }
  }
  return 0;
}