#include #include using namespace std; typedef long long ll; ll ary[12]; int main(){ ll n; cin>>n; char a; ll o=0; ll s=0; for(ll i=0; i>a; if(a=='+'){ ary[10]+=1; o+=1; } else if(a=='-'){ ary[11]+=1; o+=1; } else{ ll b=a; b-=48; ary[b]+=1; s+=1; } } ll p=0; ll m=0; if(ary[10]) p=1; if(ary[11]) m=1; ll x=0; ll y=0; vector v1,v2,v3; string s1,s2; ll d; if(p==1 && m==0){ ll ary2[12]; for(ll i=0; i<12; ++i){ ary2[i]=ary[i]; } while(1){ if(ary2[10]==0) break; ary2[10]-=1; for(ll i=0; i<10; ++i){ if(ary2[i]>0){ v1.push_back(i); ary2[i]-=1; break; } } } for(ll i=9; i>=0; --i){ while(1){ if(ary2[i]==0) break; char c=i+'0'; s1+=c; ary2[i]-=1; } } d=stol(s1); v2.push_back(d); x=v2[0]; for(ll i=0; i0){ v1.push_back(i); ary2[i]-=1; break; } } } for(ll i=9; i>=0; --i){ while(1){ if(ary2[i]==0) break; char c=i+'0'; s2+=c; ary2[i]-=1; } } d=stol(s2); v2.push_back(d); y=v2[0]; for(ll i=0; i0){ v1.push_back(i); ary2[i]-=1; break; } } } for(ll i=9; i>=0; --i){ while(1){ if(ary2[i]==0) break; char c=i+'0'; s1+=c; ary2[i]-=1; } } d=stol(s1); v2.push_back(d); x=v2[0]; y-=v2[0]; for(ll i=0; i0){ v1.push_back(i); ary2[i]-=1; break; } } } while(1){ if(ary2[10]==0) break; ary2[10]-=1; for(ll i=0; i<10; ++i){ if(ary2[i]>0){ v2.push_back(i); ary2[i]-=1; break; } } } for(ll i=9; i>=0; --i){ while(1){ if(ary2[i]==0) break; char c=i+'0'; s1+=c; ary2[i]-=1; } } d=stol(s1); v3.push_back(d); x=v3[0]; for(ll i=0; i0){ v1.push_back(i); ary2[i]-=1; break; } } } while(1){ if(ary2[11]==1) break; ary2[11]-=1; for(ll i=0; i<10; ++i){ if(ary2[i]>0){ v2.push_back(i); ary2[i]-=1; break; } } } for(ll i=9; i>=0; --i){ while(1){ if(ary2[i]==0) break; char c=i+'0'; s2+=c; ary2[i]-=1; } } d=stol(s2); v3.push_back(d); y=0; for(ll i=0; i