#include <cstdio>
const int N = 100001;
const int LG = 31;
int q;
int gcd(int a, int b)
{
int t;
while (b)
{
a = a % b;
t = a;
a = b;
b = t;
}
return a;
}
struct Node
{
int f, g;
Node *l, *r;
Node(int f_ = 0, int g_ = 0)
{
f = f_;
g = g_;
l = r = 0;
};
};
Node pool[LG * N];
int p = 0;
Node *new_node(int f, int g)
{
pool[p].f = f;
pool[p].g = g;
return &pool[p++];
}
Node *update(Node *t, int i, int v, int l = 1, int r = 1000000000)
{
if(l == r) {
if(t == 0) return new_node(1, i);
else {
t->f += v;
if(t->f == 0) return 0;
return t;
}
}
if(t == 0)
t = new_node(0, 0);
int m = (l + r) / 2;
if(i > m) t->r = update(t->r, i, v, m + 1, r);
else t->l = update(t->l, i, v, l, m);
t->g = gcd((t->l?t->l->g:0), (t->r?t->r->g:0));
return t;
}
int main(int argc, char *argv[])
{
Node *t = 0;
scanf("%d", &q);
for(int i = 0; i < q; i++)
{
char c[3];
int x;
scanf("%1s %d", c, &x);
if(c[0] == '+') t = update(t, x, 1);
else t = update(t, x, -1);
printf("%d\n", t->g == 0 ? 1 : t->g);
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KCmNvbnN0IGludCBOID0gMTAwMDAxOwpjb25zdCBpbnQgTEcgPSAzMTsKaW50IHE7CgppbnQgZ2NkKGludCBhLCBpbnQgYikKewogICAgaW50IHQ7CiAgICB3aGlsZSAoYikKICAgIHsKICAgICAgICBhID0gYSAlIGI7CiAgICAgICAgdCA9IGE7CiAgICAgICAgYSA9IGI7CiAgICAgICAgYiA9IHQ7CiAgICB9CiAgICByZXR1cm4gYTsKfQoKc3RydWN0IE5vZGUKewogICAgaW50IGYsIGc7CiAgICBOb2RlICpsLCAqcjsKCiAgICBOb2RlKGludCBmXyA9IDAsIGludCBnXyA9IDApCiAgICB7CiAgICAgICAgZiA9IGZfOwogICAgICAgIGcgPSBnXzsKICAgICAgICBsID0gciA9IDA7CiAgICB9Owp9OwoKTm9kZSBwb29sW0xHICogTl07CmludCBwID0gMDsKCk5vZGUgKm5ld19ub2RlKGludCBmLCBpbnQgZykKewogICAgcG9vbFtwXS5mID0gZjsKICAgIHBvb2xbcF0uZyA9IGc7CiAgICByZXR1cm4gJnBvb2xbcCsrXTsKfQoKTm9kZSAqdXBkYXRlKE5vZGUgKnQsIGludCBpLCBpbnQgdiwgaW50IGwgPSAxLCBpbnQgciA9IDEwMDAwMDAwMDApCnsKICAgIGlmKGwgPT0gcikgewogICAgICAgIGlmKHQgPT0gMCkgcmV0dXJuIG5ld19ub2RlKDEsIGkpOwogICAgICAgIGVsc2UgewogICAgICAgICAgICB0LT5mICs9IHY7CiAgICAgICAgICAgIGlmKHQtPmYgPT0gMCkgcmV0dXJuIDA7CiAgICAgICAgICAgIHJldHVybiB0OwogICAgICAgIH0KICAgIH0KCiAgICBpZih0ID09IDApCiAgICAgICAgdCA9IG5ld19ub2RlKDAsIDApOwoKICAgIGludCBtID0gKGwgKyByKSAvIDI7CiAgICBpZihpID4gbSkgdC0+ciA9IHVwZGF0ZSh0LT5yLCBpLCB2LCBtICsgMSwgcik7CiAgICBlbHNlIHQtPmwgPSB1cGRhdGUodC0+bCwgaSwgdiwgbCwgbSk7CgogICAgdC0+ZyA9IGdjZCgodC0+bD90LT5sLT5nOjApLCAodC0+cj90LT5yLT5nOjApKTsKCiAgICByZXR1cm4gdDsKfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkKewogICAgTm9kZSAqdCA9IDA7CgogICAgc2NhbmYoIiVkIiwgJnEpOwogICAgZm9yKGludCBpID0gMDsgaSA8IHE7IGkrKykKICAgIHsKICAgICAgICBjaGFyIGNbM107CiAgICAgICAgaW50IHg7CgogICAgICAgIHNjYW5mKCIlMXMgJWQiLCBjLCAmeCk7CiAgICAgICAgaWYoY1swXSA9PSAnKycpIHQgPSB1cGRhdGUodCwgeCwgMSk7CiAgICAgICAgZWxzZSB0ID0gdXBkYXRlKHQsIHgsIC0xKTsKCiAgICAgICAgcHJpbnRmKCIlZFxuIiwgdC0+ZyA9PSAwID8gMSA6IHQtPmcpOwogICAgfQogICAgcmV0dXJuIDA7Cn0K