#include <bits/stdc++.h>
using namespace std;
int dp[105][140050], n, a[150],
    zs[17] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53},
    fa[105][140050], ztt[60];
vector<int> zyz[60];
void Read(int &x) {
  x = 0;
  int p = 0;
  char st = getchar();
  while (st < '0' || st > '9') p = (st == '-'), st = getchar();
  while (st >= '0' && st <= '9')
    x = (x << 1) + (x << 3) + st - '0', st = getchar();
  x = p ? -x : x;
  return;
}
void Prework() {
  for (int i = 1; i <= 58; i++)
    for (int j = 0; zs[j] <= i && j < 16; j++)
      if (i % zs[j] == 0) ztt[i] |= (1 << j);
  return;
}
int Abs(int x) { return x < 0 ? -x : x; }
void Print(int pos, int zt) {
  if (pos == 0) return;
  Print(pos - 1, zt ^ ztt[fa[pos][zt]]);
  printf("%d ", fa[pos][zt]);
  return;
}
int main() {
  Prework();
  Read(n);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (1 << 16); j++) dp[i][j] = 0x7f7f7f7f;
  for (int i = 1; i <= n; i++) Read(a[i]);
  for (int i = 1; i <= 58; i++) {
    if (Abs(a[1] - i) < dp[1][ztt[i]]) {
      dp[1][ztt[i]] = Abs(a[1] - i);
      fa[1][ztt[i]] = i;
    }
  }
  for (int i = 2; i <= n; i++)
    for (int zt = 0; zt < (1 << 16); zt++)
      if (dp[i - 1][zt] != 0x7f7f7f7f)
        for (int j = 1; j <= 58; j++)
          if (!(ztt[j] & zt)) {
            if (dp[i - 1][zt] + Abs(a[i] - j) < dp[i][zt | ztt[j]]) {
              fa[i][zt | ztt[j]] = j;
              dp[i][zt | ztt[j]] = dp[i - 1][zt] + Abs(a[i] - j);
            }
          }
  int zt, ans = 0x7f7f7f7f;
  for (int i = 0; i < (1 << 16); i++)
    if (dp[n][i] < ans) ans = dp[n][i], zt = i;
  Print(n, zt);
  return 0;
}
