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 dp[105][150005], tk[105], po2[25];
int arrbt[105][150005], vl[105][150005], p[105], pr[105];
vector<int> pri;
vector<int> kn[150005], cals, pv[150000];
map<int, int> mp;
void re(int cur, int val, int bm) {
  if (val > 60) {
    return;
  }
  if (mp[val] == 0) {
    kn[bm].push_back(val);
  }
  mp[val] = 1;
  re(cur, val * pri[cur], bm | po2[cur]);
  if (cur + 1 < pri.size()) re(cur + 1, val, bm);
}
void ss(int bm, int lv) {
  if (lv == pri.size()) {
    return;
  }
}
int main() {
  po2[0] = 1;
  for (int i = 1; i < 22; i++) {
    po2[i] = po2[i - 1] * 2;
  }
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 2; i <= 60; i++) {
    if (pr[i] == 0) {
      for (int j = 2 * i; j <= 100; j += i) {
        pr[j] = 1;
      }
      pri.push_back(i);
    }
  }
  re(0, 1, 0);
  for (int i = 0; i < 150005; i++) {
    if (!kn[i].empty()) {
      cals.push_back(i);
    }
  }
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 150005; j++) dp[i][j] = 1e9;
  }
  dp[0][0] = 0;
  for (int i = 0; i < t; i++) {
    for (int j = 0; j < 150005; j++) {
      if (dp[i][j] != 1e9) {
        for (int k = 0; k < cals.size(); k++) {
          if ((cals[k] & j) == 0) {
            int pos = cals[k];
            for (int l = 0; l < kn[pos].size(); l++) {
              if (dp[i + 1][j | pos] > dp[i][j] + abs(kn[pos][l] - p[i])) {
                dp[i + 1][j | pos] = dp[i][j] + abs(kn[pos][l] - p[i]);
                arrbt[i + 1][j | pos] = j;
                vl[i + 1][j | pos] = kn[pos][l];
              }
            }
          }
        }
      }
    }
  }
  int mn = 1e9, pos = -1;
  int cc = t, cc2 = cc;
  for (int i = 0; i < 150005; i++) {
    if (mn > dp[cc2][i]) {
      mn = dp[cc2][i];
      pos = i;
    }
  }
  while (cc > 0) {
    tk[cc] = vl[cc][pos];
    pos = arrbt[cc][pos];
    cc--;
  }
  for (int i = 1; i <= cc2; i++) {
    printf("%d ", tk[i]);
  }
}