#include "bits/stdc++.h" using namespace std; typedef long long ll; #define rep(i,l,r) for(int i=(l);i<(r);i++) #define fcout cout << fixed << setprecision(10) vector card; vector permlist; ll bigMul(ll a, ll b, ll m){ int base = (int)1e9; ll a_low = a % base, a_high = a / base, b_low = b % base, b_high = b / base, result; result = (a_high * b_high) % m; rep(i, 0, 9) result = (result * 10) % m; result = (result + a_low*b_high + b_low*a_high) % m; rep(i, 0, 9) result = (result * 10) % m; result = (result + a_low*b_low) % m; return result; } //n**p % m ll bigPowMod(ll n, ll p, ll m){ ll ans = 1, ln = n; if(p <= 0) return 1; while(p != 0){ if((p & 1) == 1) ans = bigMul(ans, ln, m); //ans = (ans*ln) % m; //ln = (ln * ln) % m; ln = bigMul(ln, ln, m); p = p >> 1; } return ans; } bool suspect(int a, int s, ll d, ll n) { ll x = bigPowMod(a, d, n); if (x == 1) return true; for (int r = 0; r < s; ++r) { if (x == n - 1) return true; //x = x * x % n; x = bigMul(x, x, n); } return false; } //MillerRabin primality test // {2,7,61,-1} is for n < 4759123141 (= 2^32) // {2,3,5,7,11,13,17,19,23,-1} is for n < 10^16 (at least) int test[] = {2,3,5,7,11,13,17,19,23,-1}; bool MillerRabin(ll n) { if (n <= 1 || (n > 2 && n % 2 == 0)) return false; ll d = n - 1; int s = 0; while (d % 2 == 0){ s++; d /= 2; } for (int i = 0; test[i] < n && test[i] != -1; ++i) if (!suspect(test[i], s, d, n)) return false; return true; } bool is_prime(ll n){ if (n < 2) return false; if (n < 4) return true; if (!(n % 2)) return false; if (!(n % 3)) return false; ll sq = sqrt(n); for(int i = 5 ;i < 32; i += 4 - i % 6 / 2){ if (sq < i) return true;; if (!(n % i)) return false; } if(MillerRabin(n))return true; return false; } ll putBack(ll a, int b){ return a * (b < 10 ? 10 : 100) + b; } vector erase(vector v,int pos){ v.erase(v.begin()+pos); return v; } void permutations(vector v,ll cnt){ if(v.size()==1){ permlist.push_back(putBack(cnt, v[0])); return; } rep(i,0,v.size()){ permutations(erase(v,i), putBack(cnt, v[i])); } } int main(){ int n,a; cin >> n; card.reserve(n); rep(i, 0, n){ cin >> a; card.push_back(a); } permlist.push_back(0); permutations(card,0); sort(permlist.begin()+1, permlist.end(), greater()); rep(i,1,permlist.size())if(permlist[i-1]!=permlist[i]&&is_prime(permlist[i])){ cout<