#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int Q;

int main(){
	cin>>Q;
	ll cons=0;
	ll ans=0;
	multiset<ll> lef,rig;
	while(Q--){
		// multiset<ll>::iterator itr=lef.end();
		// multiset<ll>::iterator itr2=rig.begin();
		// itr--;
		// ll ma=(*itr);
		// ll mi=*itr2;
		// cout<<Q<<"    "<<ans<<" "<<lef.size()<<" "<<rig.size()<<" "<<ma<<" "<<mi<<endl;
		int num;
		ll a,b;
		cin>>num;
		int sz1=lef.size(),sz2=rig.size();

		if(num==1){
			cin>>a>>b;
			cons+=b;
			if(sz1==sz2){
				if(sz1==0)rig.insert(a);
				else{
					multiset<ll>::iterator itr=lef.end();
					multiset<ll>::iterator itr2=rig.begin();
					itr--;
					ll ma=*itr;
					ll mi=*itr2;
				
					if(ma<=a&&mi>=a){
						rig.insert(a);
					}else if(mi<=a){
						rig.insert(a);
						ans+=abs(mi-a);
					}else{
						lef.insert(a);
						ans+=abs(ma-a);
					}
				}
			}else{
				if(sz1>sz2){
					multiset<ll>::iterator itr=lef.end();
					itr--;
					ll ma=*itr;
					ans+=abs(ma-a);
					if(ma>=a){
						lef.erase(itr);
						lef.insert(a);
						rig.insert(ma);
					}else rig.insert(a);
					//cout<<lef.size()<<" "<<rig.size()<<endl;
				}else{
					multiset<ll>::iterator itr=rig.begin();
					ll mi=*itr;
					ans+=abs(mi-a);
					if(mi<=a){
						rig.erase(itr);
						rig.insert(a);
						lef.insert(mi);
						//cout<<mi<<"lefin"<<endl;
					}else{
						lef.insert(a);
						//multiset<ll>::iterator itr=lef.begin();
						//cout<<*itr<<"aa"<<endl;
					}
					//cout<<a<<"a"<<endl;
				}

			}
		}else{
			if(sz1+sz2==0)cout<<0<<" ";
			else if(sz1==sz2){
				multiset<ll>::iterator itr=lef.end();
				itr--;
				cout<<(*itr)<<" ";
			}else{
				if(sz1>sz2){
					multiset<ll>::iterator itr=lef.end();
					itr--;
					cout<<(*itr)<<" ";
				}else{
					multiset<ll>::iterator itr=rig.begin();
					cout<<(*itr)<<" ";
				}
			}
			cout<<ans+cons<<endl;

		}
	}
}

Measured memory_bytes: 9600