//GIVE ME AC!!!!!!!!!!!!!!!!! //#pragma GCC target("avx") //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #include #define ll long long #define ld long double #define floatset() fixed<; using vi=vector; using vs=vector; using vc=vector; using vvl=vector; using P=pair; using vvc=vector; using vd=vector; using vp=vector

; using vb=vector; const int dx[8]={1,0,-1,0,1,-1,-1,1}; const int dy[8]={0,1,0,-1,1,1,-1,-1}; const ll inf=2e18; const ll MOD=1000000007; const ll mod=998244353; const double pi=acos(-1); template ostream &operator<<(ostream&os,const pair&p) { os< istream &operator>>(istream&is,pair&p) { is>>p.first>>p.second; return is; } template ostream &operator<<(ostream&os,const vector&v) { for(int i=0;i<(int)v.size();i++) { os< istream &operator>>(istream&is,vector&v) { for(T &in:v)is>>in; return is; } void scan(){} template void scan(Head&head,Tail&... tail) { cin>>head; scan(tail...); } template void print(const T &t) { cout << t << '\n'; } template void print(const Head &head, const Tail &... tail) { cout << head << ' '; print(tail...); } template void fin(const T &... a) { print(a...); exit(0); } template ll sum_(vector&v){ ll res=0; for(auto &e:v)res+=e; return res; } template inline bool chmax(T1&a,T2 b){return a inline bool chmin(T1&a,T2 b){return a>b&&(a=b,true);} bool miller_rabin(long long n) { if(n<2)return 0; long long s=__builtin_ctzl(n-1),d=n>>s; for (auto b:{2,325,9375,28178,450775,9780504,1795265022}){ long long p=1,i=s,j=d,k=b; while(j) { if(j&1)p=(__int128)p*k%n; k=(__int128)k*k%n; j>>=1; } while (p!=1&&p!=n-1&&b%n&&i--)p=(__int128)p*p%n; if(p!=n-1&&i!=s)return 0; } return 1; } int main(){ LL(n); vl a(n); scan(a); sort(all(a)); ll ans=-1; do{ ll num=0; rep(i,0,n){ if(a[i]>=10){ num*=100; num+=a[i]; } else{ num*=10; num+=a[i]; } } if(ans