#include #include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a> n; vector a(n); rep(i,n) cin >> a[i]; if(n<=10){ sort(all(a)); string s; boost::multiprecision::cpp_int mn(string(200,'9')); do{ string now; for(auto i:a) now+=i; reverse(all(now)); boost::multiprecision::cpp_int x=0,r=1; for(auto i:now){ x+=(i-'0')*r; r*=10; } if(chmin(mn,x)) s=now; }while(next_permutation(all(a))); ll ans=0,r=1; for(auto i:s){ ans+=(i-'0')*r%mod; ans%=mod; r*=10; r%=mod; } cout << ans << '\n'; return 0; }else{ assert(0); } }