#include <bits/stdc++.h>   using namespace std;   int ini() {     int x;     scanf( %d , &x);     return x;   }   long long inl() {     long long x;     scanf( %lld , &x);     return x;   }   void file_mamager() {}   int arr[105], mask[105], dp[105][1 << 17];   pair<int, int> path[105][1 << 17];   vector<int> primes;   void gen() {     for (int i = 2; i <= 60; i++) {       bool is = true;       for (int j = 2; j * j <= i; j++) {         if (i % j == 0) {           is = false;           break;         }       }       if (is) primes.push_back(i);     }   }   void bit_rep(int x) {     for (int i = 0; i < 10; i++) cout << ((x >> i) & 1);     cout <<   n ;   }   int main() {     gen();     int n = ini();     for (int i = 1; i <= n; i++) {       for (int j = 0; j < (1 << 17); j++) dp[i][j] = 1e8;     }     for (int i = 1; i <= n; i++) arr[i] = ini();     for (int i = 1; i <= 60; i++) {       int x = 0, y = i;       for (int j = 0; j < 17; j++) {         if (y % primes[j] == 0) {           x |= (1 << j);           while (y % primes[j] == 0) y /= primes[j];         }       }       mask[i] = x;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= 60; j++) {         for (int k = 0; k < (1 << 17); k++) {           if ((k & mask[j]) == mask[j]) {             if (dp[i - 1][k ^ mask[j]] + abs(arr[i] - j) < dp[i][k]) {               dp[i][k] = dp[i - 1][k ^ mask[j]] + abs(arr[i] - j);               path[i][k] = {(k ^ mask[j]), j};             }           }         }       }     }     int mn = 1e8;     int x = (1 << 17) - 1;     for (int k = 0; k < (1 << 17); k++) {       if (dp[n][k] < mn) {         mn = dp[n][k];         x = k;       }     }     vector<int> ans;     for (int i = n; i >= 1; i--) {       ans.push_back(path[i][x].second);       x = path[i][x].first;     }     reverse(ans.begin(), ans.end());     for (int xx : ans) cout << xx <<    ;     cout <<   n ;     return 0;   }   