#include <bits/stdc++.h>
#define endl '\n'
#define left jhghajkhja
#define right oauighgajk
#define prev aioghajga
#define next ioyhjhfajasj
#define y0 iuadoghasdgj
#define y1 taklahgjkla
#define remainder pogjuakllhga
#define pow pajklgaklha
#define pow10 iopuioadjlgkah
#define div aljghajkghak
#define distance gkuftgjasgfjh
#define uppercase ifyhasjkhakjfas
#define count sajhfkajfa
//#define floor hjakjhaja
//#define time ashjlahjka
//#define double_t double
//#define tm kahjflahaajk
using namespace std;
const int N = 1<<17;
const int TREE_SIZE = N<<2;
int q;
char type[N];
int number[N];
int p[N],sz,all;
map < int, int > code;
int restore[N];
map < int, int > m;
int tree[TREE_SIZE];
int arr[TREE_SIZE];
int gcd(int a, int b) {
if(a==0 && b==0) return 0;
int r;
while(b) r=a%b,a=b,b=r;
return a;
}
void update_tree(int a, int b, int pos, int node, int value) {
if(a>b || a>pos || b<pos) return;
if(a==b) {
tree[node]+=value;
return;
}
update_tree(a,(a+b)>>1,pos,node<<1,value);
update_tree(((a+b)>>1)+1,b,pos,(node<<1)|1,value);
tree[node]=gcd(tree[node<<1],tree[(node<<1)|1]);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("test.txt","r",stdin);
//freopen("IN.c_str()","r",stdin);
//freopen("OUT.c_str()","w",stdin);
int i;
cin>>q;
for(i=1;i<=q;i++) {
cin>>type[i]>>number[i];
p[++sz]=number[i];
}
sort(p+1,p+1+sz);
code[p[1]]=1;
restore[1]=code[p[1]];
all=1;
for(i=2;i<=sz;i++) {
if(p[i]!=p[i-1]) {
++all;
code[p[i]]=all;
restore[all]=p[i];
}
}
for(i=1;i<=q;i++) {
if(type[i]=='+') {
++m[number[i]];
if(m[number[i]]==1) update_tree(1,all,code[number[i]],1,number[i]);
}
else {
--m[number[i]];
if(m[number[i]]==0) update_tree(1,all,code[number[i]],1,-number[i]);
}
printf("%d\n", ((tree[1]==0) ? 1 : tree[1]));
}
//fprintf(stderr, "Time: %d ms\n", (int)(clock()*1000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