voiddown(int u){ while (1) { int a = u << 1, b = u << 1 | 1; if (a > tp) break; if (a <= tp && b <= tp && hp[a] > hp[b]) swap(a, b); if (hp[a] < hp[u]) swap(hp[a], hp[u]); elsebreak; u = a; } }
voidup(int u){ while (1) { int a = u >> 1; if (!a || hp[a] < hp[u]) break; swap(hp[a], hp[u]); u = a; } }
intmain(){ int n, op, x; scanf("%d", &n); while (n--) { scanf("%d", &op); if (op == 1) scanf("%d", &x), hp[++tp] = x, up(tp); elseif (op == 2) printf("%d\n", hp[1]); elseswap(hp[1], hp[tp--]), down(1); } return0; }