#include <bits/stdc++.h>   using namespace std;   int tot, n;   int vis[110];   int p[110];   int dp[2][262144], cs[110][262144], pre[110][262144];   int have[100];   int a[110], b[110];   string print(int sta) {     string x =   ;     for (int i = tot - 1; i >= 0; i--) {       if (sta & (1 << i))         x +=  1 ;       else         x +=  0 ;     }     return x;   }   int main() {     for (int i = 2; i <= 59; i++) {       if (!vis[i]) p[tot++] = i;       for (int j = i; j <= 59; j += i) vis[j] = 1;     }     for (int i = 1; i <= 59; i++) {       for (int j = 0; j < tot; j++) {         if (i % p[j] == 0) have[i] |= (1 << j);       }     }     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     memset(dp, 0x3f, sizeof(dp));     dp[0][0] = 0;     register int tmp;     register int nowt = 1, pret = 0;     for (int i = 1; i <= n; i++) {       for (int sta = 0; sta < (1 << tot); sta++) {         dp[nowt][sta] = 0x3f3f3f3f;         for (int j = 1; j <= 59; j++) {           if ((have[j] & sta) != have[j]) continue;           tmp = dp[pret][have[j] ^ sta] + abs(j - a[i]);           if (tmp < dp[nowt][sta]) {             dp[nowt][sta] = tmp;             pre[i][sta] = have[j] ^ sta;             cs[i][sta] = j;           }         }       }       nowt ^= 1;       pret ^= 1;     }     int mi = 0x3f3f3f3f;     for (int i = 0; i < (1 << tot); i++) {       mi = min(mi, dp[pret][i]);     }     int pp;     for (int i = 0; i < (1 << tot); i++) {       if (mi == dp[pret][i]) {         pp = i;         for (int now = n; now >= 1; now--) {           b[now] = cs[now][pp];           pp = pre[now][pp];         }         for (int now = 1; now <= n; now++) {           printf( %d  , b[now]);         }         puts(  );         return 0;       }     }   }   