#include #include #include int main() { int n = 0, m, k, pt = 0, stk[500]; for (;;) { k = getc_unlocked(stdin); if (k < '0' || k > '9') break; n = n * 10 + k - '0'; } // printf("%d\n", n); for (int i = 0; i < n; ++i) { // printf("i=%d, n=%d\n", i, n); k = getc_unlocked(stdin); if (k == '+') { --pt; stk[pt - 1] += stk[pt]; getc_unlocked(stdin); } else if (k == '-') { --pt; stk[pt - 1] -= stk[pt]; getc_unlocked(stdin); } else { int m = k - 48; for (;;) { k = getc_unlocked(stdin); if (k < '0' || k > '9') break; m = n * 10 + k - '0'; } stk[pt++] = m; } } n = 0, m = 0, k = *stk; char f[6]; if (k < 0) { m = 1; k = -k; } while (k) { f[n++] = k % 10; k /= 10; } if (!n) f[n++] = 0; if (m) putc_unlocked('-', stdout); while (n--) putc_unlocked(f[n] + '0', stdout); return 0; }