#include <iostream>
using namespace std;
template <class POINTER_TYPE, class TYPE> class segment_tree
{
TYPE *SegmentTree;
POINTER_TYPE base_capacity = 0;
TYPE (*g)(TYPE, TYPE);
TYPE neutral;
TYPE result_on_segment_in
(
POINTER_TYPE v, POINTER_TYPE tl,
POINTER_TYPE tr, POINTER_TYPE l,
POINTER_TYPE r
)
{
if (l > r) return neutral;
else if (l == tl && r == tr) return SegmentTree[v];
else
{
POINTER_TYPE tm = (tl + tr) / 2;
return g(result_on_segment_in(v*2, tl, tm, l, min(r,tm)),
result_on_segment_in(v*2+1, tm+1, tr, max(l,tm+1), r));
}
}
void make_monoid_and_fill_rest(TYPE *NewTree, const POINTER_TYPE &n, TYPE f(TYPE, TYPE), const TYPE &neutr)
{
g = f;
neutral = neutr;
for(POINTER_TYPE i = base_capacity+n; i < 2*base_capacity; ++i)
{
NewTree[i] = neutral;
}
for(POINTER_TYPE i = base_capacity-1; i > 0; --i)
{
NewTree[i] = g(NewTree[2*i], NewTree[2*i+1]);
}
SegmentTree = NewTree;
}
void fix_capacity(const POINTER_TYPE &base_array_size)
{
for (base_capacity = 1; base_capacity < base_array_size; base_capacity <<= 1);
}
public:
void read_and_construct(const POINTER_TYPE amount_of_elements, TYPE preprocessing_function(const POINTER_TYPE&), TYPE f(TYPE, TYPE), const TYPE neutr)
{
fix_capacity(amount_of_elements);
TYPE *NewTree = new TYPE[base_capacity*2];
for(POINTER_TYPE i = 0; i < amount_of_elements; ++i)
{
NewTree[base_capacity+i] = preprocessing_function(i);
}
make_monoid_and_fill_rest(NewTree, amount_of_elements, f, neutr);
}
void assign(const POINTER_TYPE index, const TYPE new_value)
{
SegmentTree[base_capacity+index] = new_value;
for (POINTER_TYPE i = (base_capacity+index)/2; i > 0; i /= 2)
{
SegmentTree[i] = g(SegmentTree[2*i], SegmentTree[2*i+1]);
}
}
TYPE result_on_segment (POINTER_TYPE l, POINTER_TYPE r)
{
return result_on_segment_in(1, 0, base_capacity-1, l, r);
}
};
struct leaf
{
unsigned int number, amount;
leaf()
{
number = 2000000;
amount = 0;
}
leaf(unsigned int a)
{
number = a, amount = 0;
}
};
leaf max_leafs(leaf a, leaf b)
{
return
(a.amount == b.amount) ?
(a.number < b.number) ? a : b
:
(a.amount > b.amount) ? a : b;
}
leaf constructor(const unsigned int &i)
{
return leaf(i);
}
int main()
{
segment_tree <unsigned int, leaf> box;
box.read_and_construct(1000001, constructor, max_leafs, leaf());
unsigned int n, index;
char operation;
leaf tmp;
scanf("%u\n", &n); ++n;
while (--n)
{
scanf("%c %u\n", &operation, &index);
tmp = box.result_on_segment(index, index);
if (operation == '+') ++tmp.amount;
else --tmp.amount;
box.assign(index, tmp);
printf("%u\n", (box.result_on_segment(0, 1000000)).number);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPGNsYXNzIFBPSU5URVJfVFlQRSwgY2xhc3MgVFlQRT4gY2xhc3Mgc2VnbWVudF90cmVlCnsKICAgIFRZUEUgKlNlZ21lbnRUcmVlOwogICAgUE9JTlRFUl9UWVBFIGJhc2VfY2FwYWNpdHkgPSAwOwogICAgVFlQRSAoKmcpKFRZUEUsIFRZUEUpOwogICAgVFlQRSBuZXV0cmFsOwogCiAgICBUWVBFIHJlc3VsdF9vbl9zZWdtZW50X2luCiAgICAoCiAgICAgICAgUE9JTlRFUl9UWVBFIHYsIFBPSU5URVJfVFlQRSB0bCwKICAgICAgICBQT0lOVEVSX1RZUEUgdHIsIFBPSU5URVJfVFlQRSBsLAogICAgICAgIFBPSU5URVJfVFlQRSByCiAgICApCiAgICB7CiAgICAgICAgaWYgKGwgPiByKSByZXR1cm4gbmV1dHJhbDsKICAgICAgICBlbHNlIGlmIChsID09IHRsICYmIHIgPT0gdHIpIHJldHVybiBTZWdtZW50VHJlZVt2XTsKICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICBQT0lOVEVSX1RZUEUgdG0gPSAodGwgKyB0cikgL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