#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5; 

#define endl "\n"

priority_queue<int> Maxheap;
priority_queue<int,vector<int>,greater<int> > Minheap;

ll l,r,B;

void insert(int x){
	if(Maxheap.empty()) {
		Maxheap.push(x);
		l+=x;
	}
	else {
		if(x<=Maxheap.top()){
			Maxheap.push(x);
			l+=x;
			if((int)Maxheap.size()-(int)Minheap.size()>=2){
				int t=Maxheap.top();
				Maxheap.pop();
				Minheap.push(t);
				l-=t;
				r+=t; 
			}
		}
		else {
			Minheap.push(x);
			r+=x;
			if(Minheap.size()>Maxheap.size()){
				int t=Minheap.top();
				Minheap.pop();
				Maxheap.push(t);
				l+=t;
				r-=t;
			}
		}
	}
} 

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int q,op,a,b,x;
	cin>>q;
	l=r=B=0;
	while(q--){
		cin>>op;
		if(op==1) {
			cin>>a>>b;
			insert(a);
			B+=b;
		}
		else{
			if(!Maxheap.empty()) x=Maxheap.top();
			else x=0;
			cout<<x<<' '<<((ll)Maxheap.size()*x-l)+(r-(ll)Minheap.size()*x)+B<<endl;
		}
	}
	return 0;
}