// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



ll BIT[200200], BIT2[200200];

void add(int A, int B) {

	while (A < 200200) {

		BIT[A] += B;

		A += A & -A;

	}

}



ll query(int A) {

	ll kotae = 0;

	while (A > 0) {

		kotae += BIT[A];

		A -= A & -A;

	}

	return kotae;

}



void add2(int A) {

	while (A < 200200) {

		BIT2[A]++;

		A += A & -A;

	}

}



ll query2(int A) {

	ll kotae = 0;

	while (A > 0) {

		kotae += BIT2[A];

		A -= A & -A;

	}

	return kotae;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int Q;

	cin >> Q;



	int QL[200000];

	pair<int, int> Q1[200000];

	vector<int> za;

	rep(q, Q) {

		cin >> QL[q];

		if (QL[q] == 1) {

			int a, b;

			cin >> a >> b;

			Q1[q] = mp(a, b);

			za.pb(a);

		}

	}

	sort(za.begin(), za.end());



	ll B = 0;

	int k = 0;

	rep(q, Q) {

		if (QL[q] == 1) {

			k++;

			B += Q1[q].second;

			int QK = lower_bound(za.begin(), za.end(), Q1[q].first) - za.begin() + 1;

			add(QK, Q1[q].first);

			add2(QK);

		}

		else {

			int s = (k + 1) / 2;

			

			int L = 0;

			int R = 200199;

			while (L + 1 < R) {

				int H = (L + R) / 2;

				if (query2(H) >= s) R = H;

				else L = H;

			}

			int kari = za[R - 1];

			cosp(kari);

			ll R1 = query(R);

			ll R2 = query2(R);

			co(B + (R2 + R2 - k) * kari + query(200199) - R1 - R1);

		}

	}



	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.6609000674765673x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	int pn = 1;

	if (ci - cn + 16 > cm) {

		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }

		A = ct - '0';

		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;

		return pn * A;

	}

	else {

		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }

		A = ct - '0';

		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;

		return pn * A;

	}

}



const int dm = 1 << 22;

char dn[dm], * di = dn;

inline void putint(ll X, ll X2) {

	if (X == 0) {

		*di++ = '0';

	}

	else {

		if (X < 0) {

			*di++ = '-';

			X = -X;

		}

		int keta = 0;

		char C[20];

		while (X) {

			*(C + keta) = '0' + X % 10;

			X /= 10;

			keta++;

		}

		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));

	}

	*di++ = ' ';

	if (X2 == 0) {

		*di++ = '0';

	}

	else {

		if (X2 < 0) {

			*di++ = '-';

			X2 = -X2;

		}

		int keta = 0;

		char C[20];

		while (X2) {

			*(C + keta) = '0' + X2 % 10;

			X2 /= 10;

			keta++;

		}

		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));

	}

	*di++ = '\n';

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int Q = getint();



	ll X = 0;

	priority_queue<int> mae;

	priority_queue<int, vector<int>, greater<int>> ato;

	mae.push(-2e9);

	ato.push(2e9);

	int sa = 0;



	rep(i, Q) {

		if (getcha() == '1') {

			getcha();

			int a = getint();

			X += getint();



			if (sa) {

				int k = mae.top();

				if (a < k) {

					mae.pop();

					ato.push(k);

					mae.push(a);

					X += k + k;

					X -= a;

				}

				else {

					ato.push(a);

					X += a;

				}

				sa = 0;

			}

			else {

				int k = ato.top();

				if (a > k) {

					ato.pop();

					mae.push(k);

					ato.push(a);

					X += a;

					X -= k + k;

				}

				else {

					mae.push(a);

					X -= a;

				}

				sa = 1;

			}

		}

		else {

			getcha();

			int k = mae.top();

			ll ans = sa * k + X;

			putint(k, ans);

		}

	}



	fwrite_unlocked(dn, di - dn, 1, stdout);



	Would you please return 0;

}