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;
using namespace std;
int const MAXN = 64;
int spf[MAXN], pp[MAXN];
vector<int> primeFac[MAXN];
vector<int> getFactorization(int x) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
void preCal() {
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++) spf[i] = i;
  for (int i = 4; i < MAXN; i += 2) spf[i] = 2;
  for (int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
  int c = 0;
  for (int i = 2; i < MAXN; i++) {
    if (spf[i] == i)
      pp[i] = c++;
    else
      pp[i] = -1;
  }
  for (int i = 1; i < MAXN; i++) primeFac[i] = getFactorization(i);
}
int n;
vector<int> arr;
int dp[1 << 18][101];
int cal(int bitmask, int ind) {
  int& dp = ::dp[bitmask][ind];
  if (dp != -1) return dp;
  bool flag;
  int q = 1e9;
  if (ind == n - 1) {
    for (int i = 1; i < 59; i++) {
      flag = true;
      for (int j = 0; j < primeFac[i].size(); j++) {
        int bit = pp[primeFac[i][j]];
        if ((bitmask >> bit) & 1) {
          flag = false;
          break;
        }
      }
      if (flag) {
        q = min(q, abs(i - arr[ind]));
      }
    }
  } else {
    for (int i = 1; i < 59; i++) {
      flag = true;
      for (int j = 0; j < primeFac[i].size(); j++) {
        int bit = pp[primeFac[i][j]];
        if ((bitmask >> bit) & 1) {
          flag = false;
          break;
        }
      }
      if (flag) {
        int newMask = bitmask;
        for (int j = 0; j < primeFac[i].size(); j++) {
          int bit = pp[primeFac[i][j]];
          newMask = newMask | (1 << bit);
        }
        q = min(q, cal(newMask, ind + 1) + abs(i - arr[ind]));
      }
    }
  }
  return dp = q;
}
int ans;
stack<int> way;
void bulidWay(int bitmask, int ind) {
  bool flag;
  int q = 1e9, indd = -1;
  int bitt;
  if (ind == n - 1) {
    for (int i = 1; i < 59; i++) {
      flag = true;
      for (int j = 0; j < primeFac[i].size(); j++) {
        int bit = pp[primeFac[i][j]];
        if ((bitmask >> bit) & 1) {
          flag = false;
          break;
        }
      }
      if (flag) {
        if (q > abs(i - arr[ind])) {
          q = abs(i - arr[ind]);
          indd = i;
        }
      }
    }
  } else {
    for (int i = 1; i < 59; i++) {
      flag = true;
      for (int j = 0; j < primeFac[i].size(); j++) {
        int bit = pp[primeFac[i][j]];
        if ((bitmask >> bit) & 1) {
          flag = false;
          break;
        }
      }
      if (flag) {
        int newMask = bitmask;
        for (int j = 0; j < primeFac[i].size(); j++) {
          int bit = pp[primeFac[i][j]];
          newMask = newMask | (1 << bit);
        }
        if (dp[newMask][ind + 1] != -1 &&
            dp[newMask][ind + 1] + abs(i - arr[ind]) < q) {
          bitt = newMask;
          indd = i;
          q = dp[newMask][ind + 1] + abs(i - arr[ind]);
        }
      }
    }
    bulidWay(bitt, ind + 1);
  }
  way.push(indd);
}
int main() {
  preCal();
  memset(dp, -1, sizeof dp);
  cin >> n;
  arr.resize(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  ans = cal(0, 0);
  bulidWay(0, 0);
  while (way.size()) {
    cout << way.top() << " ";
    way.pop();
  }
  return 0;
}