#include using namespace std; #define MAX (1LL<<56) #define MIN -(1LL<<56) typedef long long ll; int N; ll dp[1<<15],dp2[1<<15]; char c[15]; ll solve(int,int,ll); ll solve2(int,int,ll); ll solve(int idx,int S,ll sum){ if(idx == N) return sum; ll &res = dp[S]; if(res != MAX) return res; for(int i = 0 ; i < N ; i++){ if(S >> i & 1) continue; if(idx == N-1 && (c[i] == '+' || c[i] == '-')){ return MAX; } if(sum == -1 && isdigit(c[i])){ ll nv = c[i]-'0'; res = min(res,solve(idx+1,S|(1<= 0 ; i--){ if(S >> i & 1) continue; if(idx == N-1 && (c[i] == '+' || c[i] == '-')){ return MIN; } if(sum == -1 && isdigit(c[i])){ ll nv = c[i]-'0'; res = max(res,solve2(idx+1,S|(1<> N; for(int i = 0 ; i < N ; i++){ cin >> c[i]; } sort(c,c+N); for(int i = 0 ; i < (1<