#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#define int long long
using namespace std;
multiset<int>l;
multiset<int>::iterator itr;
signed main() {
	int q; cin >> q;
	int ra = 0, rb = 0;
	for (int i = 0; i < q; i++) {
		int p; cin >> p;
		if (p == 1) {
			int a, b; cin >> a >> b;
			rb += b;
			if (!i) {
				l.insert(a);
				itr = l.begin();
			}
			else {
				l.insert(a); ra += abs(a - *itr);
				if (*itr > a) { if (l.size() % 2 == 1)ra -= *itr - *(--itr); else itr--; }
				if (l.size() % 2 == 0)itr++;
			}
		}
		else {
			if (l.size() % 2 == 0)itr--;
			cout << *itr << ' ' << ra + rb << endl;
			if (l.size() % 2 == 0)itr++;
		}
	}
	cin >> q;
}