#include <bits/stdc++.h>
using namespace std;

#define INF INT_MAX
#define LINF LLONG_MAX
#define pb(x) push_back(x)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
   
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;

void init(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("log.txt", "w", stderr);
    #else
        cin.tie(0); cout.tie(0);
        ios_base::sync_with_stdio(0);
    #endif
}

const int N = 200000;
int currIdx = 0;
int ST[N] = {0};
int ele[N];

void updateTree(int p, int v){
    ST[N/2 + p] = v;
    p += N/2;
    for(int i=p; i>1; i>>=1){
        ST[i >> 1] = __gcd(ST[i], ST[i^1]);
    }
}

int main(){
    init();
    unordered_map<int, pii> mp;
    int q, x;
    cin >> q;
    char c;
    while(q--){
        cin >> c >> x;
        switch(c){
            case '+':
                mp[x].second++;
                if(mp[x].second == 1){
                    mp[x].first = currIdx;
                    ele[currIdx] = x;
                    updateTree(currIdx, x);
                    currIdx++;
                }
                break;
            case '-':
                mp[x].second--;
                if(mp[x].second == 0){
                    updateTree(mp[x].first, 0);
                    mp.erase(x);
                }
                break;
        }
        if(mp.size() == 0)
            cout << 1 << endl;
        else
            cout << ST[1] << endl;
    }
    return 0;
}