#include <bits/stdc++.h>
using namespace std;
int n, a[105], v[105], b[105];
bool p[105];
vector<int> u;
int f[105][(1 << 17) + 5], trace[105][(1 << 17) + 5];
vector<int> x[300005];
bool ok(int i, int j) {
  if (i < j) return 0;
  int k = i - j;
  return (k & j) == 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= 59; i++) p[i] = 1;
  for (int i = 2; i <= 59; i++)
    if (p[i]) {
      for (int j = 2; j <= 59 / i; j++) p[i * j] = 0;
    }
  for (int i = 2; i <= 59; i++)
    if (p[i]) u.push_back(i);
  for (int i = 2; i <= 59; i++)
    for (int j = 0; j < int(u.size()); j++)
      if (i % u[j] == 0) {
        v[i] += (1 << j);
      }
  for (int t = 0; t <= (1 << 17) - 1; t++)
    for (int j = 2; j <= 59; j++)
      if (ok(t, v[j])) x[t].push_back(j);
  for (int i = 1; i <= n; i++)
    for (int t = 0; t <= (1 << 17) - 1; t++) {
      f[i][t] = f[i - 1][t] + a[i] - 1;
      trace[i][t] = 1;
      for (int k = 0; k < int(x[t].size()); k++) {
        int j = x[t][k];
        if (f[i][t] > f[i - 1][t - v[j]] + abs(a[i] - j)) {
          f[i][t] = f[i - 1][t - v[j]] + abs(a[i] - j);
          trace[i][t] = j;
        }
      }
    }
  int mn = 1000000100;
  int cur;
  for (int t = 0; t <= (1 << 17) - 1; t++)
    if (f[n][t] < mn) {
      mn = f[n][t];
      cur = t;
    }
  for (int i = n; i >= 1; i--) {
    b[i] = trace[i][cur];
    cur -= v[b[i]];
  }
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}
