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 Abs(int x) { return x > 0 ? x : -x; }
const int inf = 0x3f3f3f3f;
struct data {
  int x, y, z;
  data(){};
  data(int xx, int yy, int zz) : x(xx), y(yy), z(zz){};
};
data path[110][1 << 17];
data res;
int cnt = 0;
int a[110];
int temp[70];
bool vis[70];
int mp[70];
int dp[110][1 << 17];
void init() {
  memset(vis, true, sizeof(vis));
  for (int i = 2; i <= 60; ++i) {
    if (vis[i]) {
      temp[i] = cnt++;
      int j = i + i;
      while (j <= 60) {
        vis[j] = false;
        j += i;
      }
    }
  }
  memset(mp, 0, sizeof(mp));
  for (int i = 1; i <= 60; ++i) {
    for (int j = 2; j <= i; ++j) {
      if (i % j == 0 && vis[j]) {
        mp[i] |= (1 << temp[j]);
      }
    }
  }
}
void dfs(int xx, int yy, int var) {
  if (xx == 0) {
    return;
  }
  dfs(path[xx][yy].x, path[xx][yy].y, path[xx][yy].z);
  cout << path[xx][yy].z << " ";
}
int main() {
  cin.sync_with_stdio(false);
  init();
  int n, var;
  while (cin >> n) {
    var = 0;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      var = max(var, a[i]);
    }
    var = 2 * var - 1;
    memset(dp, inf, sizeof(dp));
    memset(path, 0, sizeof(path));
    dp[0][0] = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j < (1 << 17); ++j) {
        if (dp[i - 1][j] != inf) {
          for (int k = 1; k <= var; ++k) {
            if (k == 1) {
              if (dp[i][j] > dp[i - 1][j] + a[i] - 1) {
                dp[i][j] = dp[i - 1][j] + a[i] - 1;
                path[i][j] = data(i - 1, j, 1);
              }
            } else {
              if ((j & mp[k]) == 0) {
                if (dp[i][j | mp[k]] > dp[i - 1][j] + Abs(k - a[i])) {
                  dp[i][j | mp[k]] = dp[i - 1][j] + Abs(k - a[i]);
                  path[i][j | mp[k]] = data(i - 1, j, k);
                }
              }
            }
          }
        }
      }
    }
    res.z = inf;
    for (int i = 0; i < (1 << 17); ++i) {
      if (res.z > dp[n][i]) {
        res = data(n, i, dp[n][i]);
      }
    }
    dfs(res.x, res.y, path[res.x][res.y].z);
    cout << endl;
  }
  return 0;
}