#include using namespace std; #define ll long long bool IsPrime(ll num){ if (num<2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; long sqrtNum = sqrtf(num); for (long i = 3; i <= sqrtNum; i += 2){ if (num % i == 0){ return false;}} return true;} int main(){ int n,i,p=1,j,k,l; ll ans; cin>>n; int a[n]; ll t[2*n]; t[1]=1; for(i=2;i-2*n;++i)t[i]=t[i-1]*10; for(i=0;i-n;++i){cin>>a[i];p*=2;} p/=2; ll s[256]={},y[256]={}; int aa=0,bb=0; ll max=-1; for(i=0;i-p;++i){ k=i; ans=a[0]; l=a[0]>9?2:1; for(j=1;j-n;++j){ l+=a[j]>9?2:1; if(k%2)ans+=a[j]*t[l]; else{ans*=a[j]>9?100:10;ans+=a[j];} k/=2;} ll k=0; for(j=0;j-aa;++j)if(s[j]==ans){k=1;break;} if(!k)for(j=0;j-bb;++j)if(y[j]==ans){k=1;break;} if(!k){ if(IsPrime(ans)){ s[aa++]=ans; max=max>ans?max:ans;} else y[bb++]=ans; }} cout<