#include <bits/stdc++.h>
using namespace std;
int a[110];
int F[65];
int C[65];
int dp[101][150000];
int path[101][150000];
int path2[101][150000];
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
vector<int> v;
void buildPrime() {
  int i, j, k, l;
  int all = (1 << 17) - 1;
  for (int n = 2; n <= 60; n++) {
    k = 0;
    for (i = 0; i < 17; i++) {
      if (n % prime[i] == 0) k |= 1 << i;
    }
    F[n] = k;
    C[n] = all ^ k;
  }
  C[1] = all;
}
int main() {
  int n, i, j, k, l;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  buildPrime();
  for (i = 0; i <= 100; i++) {
    for (j = 0; j < 150000; j++) {
      dp[i][j] = 3000;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 1; j < a[i] * 2; j++) {
      for (k = C[j];; k = (k - 1) & C[j]) {
        if (j > 1) {
          if (i - 1 >= 0) {
            if (dp[i][k | F[j]] > dp[i - 1][k] + abs(a[i] - j)) {
              dp[i][k | F[j]] =
                  min(dp[i][k | F[j]], dp[i - 1][k] + abs(a[i] - j));
              path[i][k | F[j]] = k;
              path2[i][k | F[j]] = j;
            }
          } else {
            dp[i][F[j]] = abs(a[i] - j);
            path[i][F[j]] = -1;
            path2[i][F[j]] = j;
          }
          if (k == 0) break;
        } else {
          if (i - 1 >= 0) {
            if (dp[i][k] > dp[i - 1][k] + abs(a[i] - j)) {
              dp[i][k] = min(dp[i][k], dp[i - 1][k] + abs(a[i] - j));
              path[i][k] = k;
              path2[i][k] = j;
            }
          } else {
            if (dp[i][0] > abs(a[i] - j)) {
              dp[i][0] = abs(a[i] - j);
              path[i][0] = -1;
              path2[i][0] = j;
            }
          }
          if (k == 0) break;
        }
      }
    }
  }
  int ans = 3000;
  int x;
  for (i = 0; i < 140000; i++) {
    if (ans > dp[n - 1][i]) {
      ans = dp[n - 1][i];
      x = i;
    }
  }
  for (i = n - 1, j = x; i >= 0; i--) {
    k = path[i][j];
    l = path2[i][j];
    v.push_back(l);
    j = k;
  }
  for (i = v.size() - 1; i >= 0; i--) {
    cout << v[i] << ' ';
  }
}
