#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    int q;cin >>q;
    multiset<ll>s;
    s.insert(-INFll);
        ll sub=0;
        ll ans=0;auto it=s.begin();
    for (int i = 0; i < q; ++i) {
        int c;cin >>c;
        if(c==1){
            ll a,b;cin >>a>>b;
            sub+=b;
            s.insert(a);
            if(s.size()==2){
                it++;//ok
            }
            else {
                if (s.size() % 2 == 1) {
                    ans += abs(a - *it);
                    if (*it>a) {
                        it--;
                    }
                } else {
                    if (*it<=a)it++;
                    ans += abs(a - *(it));
                    }
            }
        }
        else {
            cout <<*it<<" "<<ans+sub<<endl;
        }
    }
}
