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 tot, n;
int vis[110];
int p[110];
int dp[2][262144], cs[110][262144], pre[110][262144];
int have[100];
int a[110], b[110];
string print(int sta) {
  string x = "";
  for (int i = tot - 1; i >= 0; i--) {
    if (sta & (1 << i))
      x += '1';
    else
      x += '0';
  }
  return x;
}
int main() {
  for (int i = 2; i <= 59; i++) {
    if (!vis[i]) p[tot++] = i;
    for (int j = i; j <= 59; j += i) vis[j] = 1;
  }
  for (int i = 1; i <= 59; i++) {
    for (int j = 0; j < tot; j++) {
      if (i % p[j] == 0) have[i] |= (1 << j);
    }
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  register int tmp;
  register int nowt = 1, pret = 0;
  for (int i = 1; i <= n; i++) {
    for (int sta = 0; sta < (1 << tot); sta++) {
      dp[nowt][sta] = 0x3f3f3f3f;
      for (int j = 1; j <= 59; j++) {
        if ((have[j] & sta) != have[j]) continue;
        tmp = dp[pret][have[j] ^ sta] + abs(j - a[i]);
        if (tmp < dp[nowt][sta]) {
          dp[nowt][sta] = tmp;
          pre[i][sta] = have[j] ^ sta;
          cs[i][sta] = j;
        }
      }
    }
    nowt ^= 1;
    pret ^= 1;
  }
  int mi = 0x3f3f3f3f;
  for (int i = 0; i < (1 << tot); i++) {
    mi = min(mi, dp[pret][i]);
  }
  int pp;
  for (int i = 0; i < (1 << tot); i++) {
    if (mi == dp[pret][i]) {
      pp = i;
      for (int now = n; now >= 1; now--) {
        b[now] = cs[now][pp];
        pp = pre[now][pp];
      }
      for (int now = 1; now <= n; now++) {
        printf("%d ", b[now]);
      }
      puts("");
      return 0;
    }
  }
}