#include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int s[50]; int main() { int N,pl=0,min=0; cin >> N; int j = 0,k =0; for (int i = 0; i < N; i++) { char c; cin >> c; if (c >= '0' && c <= '9') s[j++] = c-'0'; else { if (c == '+')pl++; else min++; } } sort(s, s + j); reverse(s+1,s+j); ll mi = s[0], sum = pl + min,sum1; int min_t = min, pl_t = pl; sum1 = sum; string num1 = ""; char ope; for (int i = 1; i < j; i++) { if (sum != 0) { if (min != 0) { ope = '-'; min--; } else if (pl != 0) { ope = '+'; pl--; } sum--; } num1 += to_string(s[i]); if (sum != 0) { if (ope == '-') { mi = mi - stoll(num1); } else if (ope == '+') mi = mi + stoll(num1); num1 = ' '; } } if (ope == '-')mi = mi - stoll(num1); else if (ope == '+')mi = mi + stoll(num1); sort(s, s + j); reverse(s, s+j); ll mx = 0; num1 = ' '; ope = '+'; for (int i = 0; i < j; i++) { if (j - (i + 1)