#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
multiset<int>h1,h2;
ll s1,s2;
void push(int x){
	if(!h1.empty()&&x<*h1.rbegin()){   //先插入小堆
		h1.insert(x);
		s1+=x;
	}
	else{
		h2.insert(x);
		s2+=x;
	}
	while(h1.size()>h2.size()){
		const int cur=*h1.rbegin();
		h2.insert(cur);
		auto it=h1.end();
		it--;
		h1.erase(it);
		s1-=cur;
		s2+=cur;
	}
	while(h2.size()>h1.size()){
		const int cur=*h2.begin();
		h1.insert(cur);
		h2.erase(h2.begin());
		s1+=cur;
		s2-=cur;
	 }
 }
 ll num;
 int main(){
	int q;
	cin>>q;
	while(q--){
		int n;
		cin>>n;
		if(n==1){
			int a,b;
			cin>>a>>b;
			num+=b;
			push(a);
		}
		else{
			int x=*h1.rbegin();
	ll ans=1ll*x*(int)(h1.size())-s1+s2-1ll*x*(int)(h2.size())+num;
	    cout<<x<<' '<<ans<<'\n';
		}
	}
}
