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>
inline void read(int &a) {
  register char ch;
  a = 0;
  int sign = 1;
  do {
    ch = getchar();
  } while (!isdigit(ch) && ch != '-');
  if (ch == '-') {
    sign = -1;
    ch = getchar();
  }
  do {
    a = a * 10 + ch - '0';
    ch = getchar();
  } while (isdigit(ch));
  a *= sign;
}
inline void write(int a) {
  char s[20];
  int i = 0;
  int sign = 1;
  if (a < 0) sign = -1, a = -a;
  do {
    s[i++] = a % 10 + '0';
    a /= 10;
  } while (a);
  i--;
  if (sign == -1) putchar('-');
  while (i >= 0) putchar(s[i--]);
}
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int dl[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int INF = 2e9;
const double EPS = 1e-9;
const int Nmax = 1e2 + 2;
const int Pmax = 16;
const int PP = 1 << Pmax;
const int Vmax = 60;
const int LgMax = log2(Nmax) + 1;
using namespace std;
int b[Pmax] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int dp[Nmax][PP];
int dad[Nmax][PP];
int value[Nmax][PP];
int A[Nmax], B[Nmax];
int mask[Vmax];
int N;
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 1; i < Vmax; ++i)
    for (int j = 0; j < Pmax; ++j)
      if (i % b[j] == 0) mask[i] |= (1 << j);
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j < PP; ++j) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int state = 0; state < PP; ++state) {
      for (int val = 1; val < Vmax; ++val) {
        if ((state & mask[val]) == 0) {
          if (dp[i + 1][state | mask[val]] > dp[i][state] + abs(A[i] - val)) {
            dp[i + 1][state | mask[val]] = dp[i][state] + abs(A[i] - val);
            dad[i + 1][state | mask[val]] = state;
            value[i + 1][state | mask[val]] = val;
          }
        }
      }
    }
  }
  int minim = INF;
  int pos = -1;
  for (int state = 0; state < PP; ++state) {
    if (dp[N][state] < minim) {
      minim = dp[N][state];
      pos = state;
    }
  }
  for (int i = N; i >= 1; i--) {
    int stare = dad[i][pos];
    int val = value[i][pos];
    B[i - 1] = val;
    pos = stare;
  }
  for (int i = 0; i < N; ++i) cout << B[i] << " ";
  return 0;
}