#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int SZ = 17;
const int MAX = 60;
int primes[MAX];
int prime[MAX];
int dp[N][1 << SZ];
int n;
int arr[N];
void pre() {
  memset(primes, -1, sizeof(primes));
  primes[2] = 0;
  primes[3] = 1;
  primes[5] = 2;
  primes[7] = 3;
  primes[11] = 4;
  primes[13] = 5;
  primes[17] = 6;
  primes[19] = 7;
  primes[23] = 8;
  primes[29] = 9;
  primes[31] = 10;
  primes[37] = 11;
  primes[41] = 12;
  primes[43] = 13;
  primes[47] = 14;
  primes[53] = 15;
  primes[59] = 16;
  for (int i = 2; i < MAX; ++i) {
    prime[i] = 0;
    for (int j = 2; j <= i; ++j) {
      if (primes[j] != -1 && i % j == 0) {
        prime[i] |= 1 << primes[j];
      }
    }
  }
  memset(dp, -1, sizeof(dp));
}
int abs(int a) { return max(a, -a); }
int solve(int pos, int mask) {
  if (pos > n) {
    return 0;
  }
  if (dp[pos][mask] != -1) {
    return dp[pos][mask];
  }
  int mn = INT_MAX;
  for (int i = 1; i < MAX; ++i) {
    int temp = abs(i - arr[pos]);
    int newmask = prime[i];
    if ((newmask & mask) == 0) {
      temp += solve(pos + 1, newmask | mask);
      if (temp < mn) {
        mn = temp;
      }
    }
  }
  return dp[pos][mask] = mn;
}
void build(int pos, int mask) {
  if (pos > n) {
    return;
  }
  int mn = INT_MAX;
  int go = -1;
  int gomask = -1;
  for (int i = 1; i < MAX; ++i) {
    int temp = abs(i - arr[pos]);
    int newmask = prime[i];
    if ((newmask & mask) == 0) {
      temp += solve(pos + 1, newmask | mask);
      if (temp < mn) {
        mn = temp;
        go = i;
        gomask = mask | newmask;
      }
    }
  }
  cout << go << " ";
  build(pos + 1, gomask);
}
int main() {
  pre();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  solve(1, 0);
  build(1, 0);
}
