#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T MIN_3(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T MAX_3(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T BIGMOD(T n, T m, T mod) {
  long long int ans = 1;
  long long int k = n;
  while (m) {
    if (m & 1) {
      ans *= k;
      if (ans > mod) ans %= mod;
    }
    k *= k;
    if (k > mod) k %= mod;
    m >>= 1;
  }
  return ans;
}
template <class T>
string toString(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
template <class T>
string toBinary(T n) {
  string ret = "";
  while (n) {
    if (n % 2 == 1)
      ret += '1';
    else
      ret += '0';
    n >>= 1;
  }
  reverse(ret.begin(), ret.end());
  return ret;
}
void combination(int n, vector<vector<int> > &ret) {
  ret.resize(n + 1, vector<int>(n + 1, 0));
  for (int i = 1; i <= n; i++) {
    ret[i][0] = ret[i][i] = 1;
    for (int j = 1; j < i; j++) {
      ret[i][j] = ret[i - 1][j] + ret[i - 1][j - 1];
    }
  }
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
long long int toLInt(string s) {
  long long int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
double toDouble(string s) {
  double r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
vector<string> parse(string temp) {
  vector<string> ans;
  ans.clear();
  string s;
  istringstream iss(temp);
  while (iss >> s) ans.push_back(s);
  return ans;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T power(T b, T p) {
  if (p < 0) return -1;
  if (b <= 0) return -2;
  if (!p) return 1;
  return b * power(b, p - 1);
}
template <class T>
inline int asd(T &ret) {
  char r;
  bool start = false, neg = false;
  ret = 0;
  bool isaNumber = false;
  while (true) {
    r = getchar();
    if (r == EOF) {
      return 0;
    }
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && !start) {
      continue;
    }
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && start) {
      break;
    }
    if (start) ret *= 10;
    start = true;
    if (r == '-')
      neg = true;
    else
      ret += r - '0';
  }
  if (neg) ret *= -1;
  return 1;
}
template <class T>
inline void asdasd(T x, char y) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  char buf[21], *p = buf;
  do {
    *p++ = '0' + x % 10;
    x /= 10;
  } while (x);
  do {
    putchar(*--p);
  } while (p > buf);
  if (y == 0)
    putchar('\n');
  else if (y == 1)
    putchar(' ');
}
vector<int> pr;
int inp[101];
int dp[101][1 << 16];
int go[101][1 << 16];
int n;
int bp[61];
void make(int &ret, int n) {
  for (int i = 0; i <= pr.size() - 1; i++) {
    if (n % pr[i] == 0) ret |= (1 << i);
  }
}
int inf = 100000000, sat = (1 << 16) - 1;
int rec(int pos, int mask) {
  if (pos == n) return 0;
  int &ret = dp[pos][mask];
  if (ret != -1) return ret;
  ret = inf;
  int now;
  for (int i = 1; i <= 58; i++) {
    if ((bp[i] & mask) == 0) {
      now = abs(inp[pos] - i) + rec(pos + 1, mask | bp[i]);
      if (ret > now) {
        ret = now;
        go[pos][mask] = i;
      }
    }
  }
  return ret;
}
vector<int> ans;
void path(int pos, int mask) {
  if (pos == n) return;
  ans.push_back(go[pos][mask]);
  path(pos + 1, mask | bp[go[pos][mask]]);
}
int main() {
  for (int i = 2; i <= 60; i++) {
    bool ok = true;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) {
        ok = false;
        break;
      }
    }
    if (ok) pr.push_back(i);
  }
  for (int i = 2; i <= 60; i++) {
    make(bp[i], i);
  }
  asd(n);
  for (int i = 0; i <= n - 1; i++) {
    asd(inp[i]);
  }
  memset(dp, -1, sizeof(dp));
  rec(0, 0);
  path(0, 0);
  for (int i = 0; i <= ans.size() - 1; i++) asdasd(ans[i], i != ans.size() - 1);
  return 0;
}
