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;
const int N = 105;
const int SZ = 17;
const int MAX = 60;
int primes[MAX];
int prime[MAX];
int dp[N][1 << SZ];
int n;
int arr[N];
void pre() {
  memset(primes, -1, sizeof(primes));
  primes[2] = 0;
  primes[3] = 1;
  primes[5] = 2;
  primes[7] = 3;
  primes[11] = 4;
  primes[13] = 5;
  primes[17] = 6;
  primes[19] = 7;
  primes[23] = 8;
  primes[29] = 9;
  primes[31] = 10;
  primes[37] = 11;
  primes[41] = 12;
  primes[43] = 13;
  primes[47] = 14;
  primes[53] = 15;
  primes[59] = 16;
  for (int i = 2; i < MAX; ++i) {
    prime[i] = 0;
    for (int j = 2; j <= i; ++j) {
      if (primes[j] != -1 && i % j == 0) {
        prime[i] |= 1 << primes[j];
      }
    }
  }
  memset(dp, -1, sizeof(dp));
}
int abs(int a) { return max(a, -a); }
int solve(int pos, int mask) {
  if (pos > n) {
    return 0;
  }
  if (dp[pos][mask] != -1) {
    return dp[pos][mask];
  }
  int mn = INT_MAX;
  for (int i = 1; i < MAX; ++i) {
    int temp = abs(i - arr[pos]);
    int newmask = prime[i];
    if ((newmask & mask) == 0) {
      temp += solve(pos + 1, newmask | mask);
      if (temp < mn) {
        mn = temp;
      }
    }
  }
  return dp[pos][mask] = mn;
}
void build(int pos, int mask) {
  if (pos > n) {
    return;
  }
  int mn = INT_MAX;
  int go = -1;
  int gomask = -1;
  for (int i = 1; i < MAX; ++i) {
    int temp = abs(i - arr[pos]);
    int newmask = prime[i];
    if ((newmask & mask) == 0) {
      temp += solve(pos + 1, newmask | mask);
      if (temp < mn) {
        mn = temp;
        go = i;
        gomask = mask | newmask;
      }
    }
  }
  cout << go << " ";
  build(pos + 1, gomask);
}
int main() {
  pre();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  solve(1, 0);
  build(1, 0);
}