#include <bits/stdc++.h>
int prime[20], binary[60];
int sum[100][1 << 10][7];
struct Node {
  int value, last_state, last_used;
} num[100][1 << 10][7];
void PrintAns(int n, int state, int used) {
  if (n < 0) {
    return;
  }
  PrintAns(n - 1, num[n][state][used].last_state,
           num[n][state][used].last_used);
  if (n != 0) {
    printf(" ");
  }
  printf("%d", num[n][state][used].value);
}
inline int abs(int o) {
  if (o < 0) {
    o = -o;
  }
  return o;
}
int main() {
  prime[0] = 0;
  for (int i = 2; i < 59; i++) {
    bool check = false;
    for (int j = 2; j <= i / 2; j++)
      if (i % j == 0) check = true;
    if (!check) prime[++prime[0]] = i;
  }
  memset(sum, 0xff, sizeof(sum));
  for (int i = 2; i < 59; i++) {
    binary[i] = 0;
    for (int j = 1; j <= 10; j++)
      if (i % prime[j] == 0) binary[i] |= (1 << (j - 1));
  }
  int turn = 0;
  memset(sum, 0xff, sizeof(sum));
  int n;
  scanf("%d", &n);
  int a[110];
  int tot = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++)
    if (i == 0) {
      for (int j = 1; j < 59; j++)
        if ((binary[j] == 0) && (j > 1)) {
          sum[i][0][1] = prime[11] - a[i];
          num[i][0][1].value = prime[11];
        } else {
          int temp = abs(j - a[i]);
          if ((sum[i][binary[j]][0] == -1) || (sum[i][binary[j]][0] > temp)) {
            sum[i][binary[j]][0] = temp;
            num[i][binary[j]][0].value = j;
          }
        }
    } else {
      for (int j = 0; j < 1024; j++)
        for (int k = 0; k < 7; k++)
          if (sum[i - 1][j][k] != -1)
            for (int l = 1; l < 59; l++)
              if ((binary[l] & j) == 0) {
                int state = (binary[l] | j), used = k, diff = 0;
                int temp = l;
                if ((binary[l] == 0) && (l > 1)) {
                  used++;
                  if (used > 6) {
                    continue;
                  }
                  diff = prime[used + 10] - a[i];
                  temp = prime[used + 10];
                } else {
                  diff = abs(l - a[i]);
                }
                diff += sum[i - 1][j][k];
                if ((sum[i][state][used] == -1) ||
                    (sum[i][state][used] > diff)) {
                  sum[i][state][used] = diff;
                  num[i][state][used].value = temp;
                  num[i][state][used].last_state = j;
                  num[i][state][used].last_used = k;
                }
              }
    }
  int ans_sum = 1e9, state = 0, used = 0;
  for (int i = 0; i < 1024; i++)
    for (int j = 0; j < 7; j++)
      if ((sum[n - 1][i][j] > -1) && (sum[n - 1][i][j] < ans_sum)) {
        ans_sum = sum[n - 1][i][j];
        state = i;
        used = j;
      }
  PrintAns(n - 1, state, used);
  printf("\n");
  return 0;
}
