#include <bits/stdc++.h>   using namespace std;   const int N = 101;   int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};   const int sz = sizeof(prime) / sizeof(int), V = 58;   int pos[V + 1], dp[N][1 << sz], n, A[N], minPrime[V + 1], trace[N][1 << sz];   void prepare() {     for (int i = 2; i * i <= V; ++i)       if (!minPrime[i])         for (int j = i * i; j <= V; j += i)           if (!minPrime[j]) minPrime[j] = i;     for (int i = 2; i <= V; ++i)       if (!minPrime[i]) minPrime[i] = i;     for (int i = 0; i < sz; ++i) pos[prime[i]] = i;   }   int solve(int idx, int msk) {     if (idx > n) return 0;     int &res = dp[idx][msk];     if (res != INT_MAX) return res;     int s, val, d;     for (int x = 1; x <= 58; ++x) {       val = x;       d = -1;       s = 0;       while (val > 1) {         if (minPrime[val] != d) {           d = minPrime[val];           s |= (1 << pos[d]);         }         val /= d;       }       if (!(s & msk)) {         val = abs(x - A[idx]) + solve(idx + 1, msk | s);         if (val < res) {           res = val;           trace[idx][msk] = x;         }       }     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; ++i) cin >> A[i];     fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(int), INT_MAX);     prepare();     solve(1, 0);     int msk = 0, val, d, s;     for (int i = 1; i <= n; ++i) {       val = trace[i][msk];       cout << val <<    ;       d = -1;       s = 0;       while (val > 1) {         if (minPrime[val] != d) {           d = minPrime[val];           s |= (1 << pos[d]);         }         val /= d;       }       msk |= s;     }     return 0;   }   