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 long long int MOD = 1000000007;
const long long BIG = 1446803456761533460LL;
const int Big = 336860180;
const long long int INF = LONG_LONG_MAX;
const vector<vector<long long int> > adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vector<vector<long long int> > adj8(
    {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
bool isprime(long long int n) {
  if (n == 2 || n == 3) return true;
  if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 6; (i - 1) * (i - 1) <= n; i += 6) {
    if (n % (i - 1) == 0 || n % (i + 1) == 0) {
      return false;
    }
  }
  return true;
}
vector<bool> sprime;
void genPrime(long long int sz) {
  sprime = vector<bool>(sz, true);
  sprime[0] = false;
  sprime[1] = false;
  for (long long int i = (2); i < (sz); ++i) {
    if (sprime[i]) {
      for (long long int j = i * i; j < sz; j += i) {
        sprime[j] = false;
      }
    }
  }
}
long long int powMod(long long int a, long long int b, long long int mod) {
  long long int n = 1;
  long long int p = a;
  while (b > 0) {
    if (b % 2 == 1) {
      n *= p;
      n %= mod;
    }
    p *= p;
    p %= mod;
    b /= 2;
  }
  return n;
}
long long int modularInverse(long long int a, long long int mod) {
  return powMod(a, mod - 2, mod);
}
long long int binarysearch(long long int l, long long int r,
                           bool (*bsfunction)(long long int)) {
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    bool val = bsfunction(mid);
    if (val) {
      r = mid;
    } else {
      l = mid;
    }
  }
  return l;
}
stringstream sss;
const long long int maxn = 110;
const long long int pr[] = {2,  3,  5,  7,  11, 13, 17, 19,
                            23, 29, 31, 37, 41, 43, 47, 53};
const long long int pn = sizeof(pr) / sizeof(long long int);
const long long int sz = 1LL << pn;
long long int a[maxn];
long long int dp[maxn][sz];
long long int dpi[maxn][sz][2];
long long int res[maxn];
long long int bts[60];
void MAIN() {
  for (long long int g = (1); g < (59); ++g) {
    for (long long int j = 0; j < (pn); ++j) {
      if (g % pr[j] == 0) {
        bts[g] |= 1 << j;
      }
    }
  }
  long long int n;
  cin >> n;
  for (long long int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  memset(dp, 20, sizeof dp);
  dp[0][0] = 0;
  for (long long int i = 0; i < (n); ++i) {
    for (long long int b = 0; b < (sz); ++b) {
      for (long long int g = (1); g < (59); ++g) {
        if ((bts[g] & b) == 0) {
          long long int v = dp[i][b] + abs(a[i] - g);
          long long int nw = b | bts[g];
          if (v < dp[i + 1][nw]) {
            dp[i + 1][nw] = v;
            dpi[i + 1][nw][0] = g;
            dpi[i + 1][nw][1] = b;
          }
        }
      }
    }
  }
  long long int mn = 0;
  for (long long int i = 0; i < (sz); ++i) {
    if (dp[n][i] < dp[n][mn]) {
      mn = i;
    }
  }
  for (long long int i = (n)-1; i >= 0; --i) {
    res[i] = dpi[i + 1][mn][0];
    mn = dpi[i + 1][mn][1];
  }
  for (long long int i = 0; i < (n); ++i) {
    cout << res[i] << ' ';
  }
  cout << endl;
}
const long long int TESTCASEN = 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  sss << R"(
100 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
40
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
5
1 6 4 2 8
    )";
  for (long long int i = 0; i < (TESTCASEN); ++i) {
    MAIN();
  }
  return 0;
}