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;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
struct P {
  double x, y;
  P() {}
  P(double x, double y) : x(x), y(y) {}
  P operator+(const P &a) const { return P(x + a.x, y + a.y); }
  P operator-(const P &a) const { return P(x - a.x, y - a.y); }
  double operator^(const P &a) const { return x * a.x + y * a.y; }
  void in() { scanf("%lf%lf", &x, &y); }
  void out() { printf("REQUIRED %.7f %.7f\n", x, y); }
  double dist(P a, P b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
  }
  double sqdist(P a, P b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
  }
};
int n;
int a[201];
int dp[102][70001], re[101][70001][2];
int mi;
int co[20];
int pos[201];
int cst;
int p[18] = {0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
int ct[59], lis[59][5];
int solve(int c, int b) {
  if (c == n + 1) return 0;
  if (dp[c][b] == -1) {
    int beta[20];
    for (int j = (1); j <= (16); j++) beta[j] = 0;
    int r = b, tt = 1;
    while (r) {
      beta[tt++] = r % 2;
      r /= 2;
    }
    dp[c][b] = solve(c + 1, b) + abs(a[c] - 1);
    re[c][b][1] = 1;
    re[c][b][0] = b;
    for (int j = (2); j <= (58); j++) {
      bool ok = true;
      int num = b;
      for (int k = (1); k <= (ct[j]); k++) {
        if (beta[lis[j][k]]) {
          ok = false;
        }
        num += co[lis[j][k]];
      }
      if (ok) {
        if (dp[c][b] > solve(c + 1, num) + abs(a[c] - j)) {
          dp[c][b] = solve(c + 1, num) + abs(a[c] - j);
          re[c][b][1] = j;
          re[c][b][0] = num;
        }
      }
    }
  }
  return dp[c][b];
}
int main() {
  scanf("%d", &n);
  co[1] = 1;
  for (int i = (2); i <= (58); i++) {
    ct[i] = 0;
    int xx = i;
    int yy = 1;
    while (xx != 1) {
      if (xx % p[yy] == 0) {
        ct[i]++;
        lis[i][ct[i]] = yy;
        while (xx % p[yy] == 0) xx /= p[yy];
      }
      yy++;
    }
  }
  for (int i = (2); i <= (16); i++) co[i] = co[i - 1] * 2;
  cst = 65535;
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i]);
  for (int i = (0); i <= (101); i++)
    for (int j = (0); j <= (cst); j++) dp[i][j] = -1;
  solve(1, 0);
  int st[41];
  int cur = 0;
  for (int i = (1); i <= (n); i++) st[i] = 1;
  for (int i = (1); i <= (n); i++) {
    printf("%d ", re[i][cur][1]);
    cur = re[i][cur][0];
  }
  puts("");
  return 0;
}