#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 200005

ll arr[MAXN] = {0}, aux[MAXN] = {0};

ll t[4*MAXN]={0}, t2[4*MAXN]={0};
void build(ll node, ll start, ll end){
    if(start == end){
        t[node] = arr[start];
        return ;
    }
    ll mid = (start + end) / 2;
    build(2*node, start, mid);
    build(2*node+1, mid+1, end);
    t[node] = t[2*node] + t[2*node+1]; 
}

void update(ll node, ll start, ll end, ll idx, ll val){
    if(start == end){
        aux[idx] = 1;
        arr[idx] = val;
        t[node] = val;
        t2[node] = 1;
        return ;
    }
    ll mid = (start + end) / 2;
    if(idx >= start && idx <= mid){
        update(2*node, start, mid, idx, val);
    }
    else {
        update(2*node+1, mid+1, end, idx, val);
    }
    t[node] = t[2*node] + t[2*node+1];
    t2[node] = t2[2*node] + t2[2*node+1];
}

ll query(ll node, ll start, ll end, ll l, ll r){
    if(r < start || l > end || l>r){
        return 0;    // range represented by node is completely outside the given range
    }
    else if(l <= start && r >= end){
        return t[node];  // range represented by a node is completely inside the given range
    }
    // range represented by a node is partially inside and partially outside the given range
    ll mid = (start + end) / 2;
    ll p1 = query(2*node, start, mid, l, r);
    ll p2 = query(2*node+1, mid+1, end, l, r);
    return (p1 + p2);
}

ll query2(ll node, ll start, ll end, ll l, ll r){
    if(r < start || l > end || l>r){
        return 0;    // range represented by node is completely outside the given range
    }
    else if(l <= start && r >= end){
        return t2[node];  // range represented by a node is completely inside the given range
    }
    // range represented by a node is partially inside and partially outside the given range
    ll mid = (start + end) / 2;
    ll p1 = query2(2*node, start, mid, l, r);
    ll p2 = query2(2*node+1, mid+1, end, l, r);
    return (p1 + p2);
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    

    ll q;
    cin>>q;
    ll a[q];
    ll ptr=0;
    ll queries[q][3];
    for(ll i=0; i<q; i++){
        ll x;
        cin>>x;
        if(x==1){
            ll aa, b;
            cin>>aa>>b;
            a[ptr] = aa;
            ptr++;
            queries[i][0] = 1, queries[i][1] = aa, queries[i][2] = b;

        }
        else if(x==2){
            queries[i][0] = 2;
            queries[i][1] = queries[i][2] = -1;
        }
    }

    map<ll, vl> m;
    map<ll,ll> pointer;
    sort(a,a+ptr);
    loop(i,0,ptr){
        m[a[i]].pb(i);
        pointer[a[i]] = 0;
    }

    indexed_set s;
    ll io = 1;
    ll constant = 0;
    loop(i,0,q){
        if(queries[i][0] == 1){
            s.insert(mp(queries[i][1], io));
            io++;
            constant+=queries[i][2];
            ll x = queries[i][1];
            update(1, 0, q-1, m[x][pointer[x]], x);
            pointer[x]++;
        }
        else if(queries[i][0] == 2){
            if(i == 0) cout<<0<<" "<<0<<endl;
            else {
                // for(auto x: s){
                //     cout<<x.fi<<" ";
                // }
                // cout<<endl;
                ll idx = (s.size()-1) / 2;
                auto itr = s.find_by_order(idx);
                ll val = (*itr).fi;
                ll index_l = m[val][0];
                ll index_r = m[val][m[val].size()-1];
                ll aaa = query(1, 0, q-1, 0, index_l - 1);
                ll bbb = query(1, 0, q-1, index_r + 1, q-1);
                ll live_l = query2(1, 0, q-1, 0, index_l - 1); 
                ll live_r = query2(1, 0, q-1, index_r + 1, q-1);
                ll ans = -aaa + bbb + val*(live_l) - val*(live_r);
                ans += constant;
                cout<<val<<" "<<ans<<endl;
            }
        }
    }




    
}



Measured memory_bytes: 41344