#include <cstdio>
#include <map>
#define maxN 100010
using namespace std;
int tree[maxN*4 + 1];
map< int, int > pos, freq;
char sign;
int num, f, q, last;
inline int gcd( int a, int b ) {
int r;
while( b != 0 ) {
r = a % b;
a = b;
b = r;
}
return a;
}
inline void update( int idx, int l, int r, int p, int val ) {
if( l == r ) {
tree[idx] += val;
return;
} else {
int mid = (l + r) / 2;
if( p <= mid )
update(idx*2, l, mid, p, val);
else
update(idx*2+1, mid+1, r, p, val);
}
tree[idx] = gcd(tree[idx*2], tree[idx*2 + 1]);
}
int main( void ) {
// freq[i] : frquency of number (i), pos[i] : position of number (i) in the list
scanf("%i", &q);
last = 1;
while( q-- ) {
scanf(" %c%i", &sign, &num);
if( sign == '-' ) {
f = --freq[num];
if( f == 0 ) {
// should remove it
update(1, 0, maxN-1, pos[num], -num);
pos[num] = 0;
}
} else {
f = freq[num]++;
if( f == 0 ) {
// it didn't exists in the list must add it
update(1, 0, maxN-1, last, num);
pos[num] = last;
}
}
last++;
printf("%i\n", tree[1] == 0 ? 1 : tree[1]);
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPG1hcD4KCiNkZWZpbmUgbWF4TiAxMDAwMTAKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgdHJlZVttYXhOKjQgKyAxXTsKbWFwPCBpbnQsIGludCA+IHBvcywgZnJlcTsKY2hhciBzaWduOyAKaW50IG51bSwgZiwgcSwgbGFzdDsKCmlubGluZSBpbnQgZ2NkKCBpbnQgYSwgaW50IGIgKSB7CiAgICBpbnQgcjsKICAgIAogICAgd2hpbGUoIGIgIT0gMCApIHsKICAgICAgICByID0gYSAlIGI7CiAgICAgICAgYSA9IGI7CiAgICAgICAgYiA9IHI7CiAgICB9ICAgIAogICAgCiAgICByZXR1cm4gYTsKfQoKaW5saW5lIHZvaWQgdXBkYXRlKCBpbnQgaWR4LCBpbnQgbCwgaW50IHIsIGludCBwLCBpbnQgdmFsICkgewogICAgaWYoIGwgPT0gciApIHsKICAgICAgICB0cmVlW2lkeF0gKz0gdmFsOwogICAgICAgIHJldHVybjsKICAgIH0gZWxzZSB7CiAgICAgICAgaW50IG1pZCA9IChsICsgcikgLyAyOwogICAgICAgIAogICAgICAgIGlmKCBwIDw9IG1pZCApCiAgICAgICAgICAgIHVwZGF0ZShpZHgqMiwgbCwgbWlkLCBwLCB2YWwpOwogICAgICAgIGVsc2UKICAgICAgICAgICAgdXBkYXRlKGlkeCoyKzEsIG1pZCsxLCByLCBwLCB2YWwpOwogICAgfQogICAgCiAgICB0cmVlW2lkeF0gPSBnY2QodHJlZVtpZHgqMl0sIHRyZWVbaWR4KjIgKyAxXSk7Cn0KCmludCBtYWluKCB2b2lkICkgewoKICAgIC8vIGZyZXFbaV0gOiBmcnF1ZW5jeSBvZiBudW1iZXIgKGkpLCBwb3NbaV0gOiBwb3NpdGlvbiBvZiBudW1iZXIgKGkpIGluIHRoZSBsaXN0IAoKICAgIHNjYW5mKCIlaSIsICZxKTsKICAgIAogICAgbGFzdCA9IDE7CiAgICB3aGlsZSggcS0tICkgewogICAgICAgIHNjYW5mKCIgJWMlaSIsICZzaWduLCAmbnVtKTsKICAgICAgICAKICAgICAgICBpZiggc2lnbiA9PSAnLScgKSB7IAogICAgICAgICAgICBmID0gLS1mcmVxW251bV07CiAgICAgICAgICAgIAogICAgICAgICAgICBpZiggZiA9PSAwICkgewogICAgICAgICAgICAgICAgLy8gc2hvdWxkIHJlbW92ZSBpdCAKICAgICAgICAgICAgICAgIHVwZGF0ZSgxLCAwLCBtYXhOLTEsIHBvc1tudW1dLCAtbnVtKTsKICAgICAgICAgICAgICAgIHBvc1tudW1dID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBmID0gZnJlcVtudW1dKys7CiAgICAgICAgICAgIAogICAgICAgICAgICBpZiggZiA9PSAwICkgewogICAgICAgICAgICAgICAgLy8gaXQgZGlkbid0IGV4aXN0cyBpbiB0aGUgbGlzdCBtdXN0IGFkZCBpdAogICAgICAgICAgICAgICAgdXBkYXRlKDEsIDAsIG1heE4tMSwgbGFzdCwgbnVtKTsKICAgICAgICAgICAgICAgIHBvc1tudW1dID0gbGFzdDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIAogICAgICAgIGxhc3QrKzsKICAgICAgICBwcmludGYoIiVpXG4iLCB0cmVlWzFdID09IDAgPyAxIDogdHJlZVsxXSk7CiAgICB9CiAgICAKICAgIHJldHVybiAwOwp9