// 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.6290749834730724x):
#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





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int Q;

	cin >> Q;



	ll maeX = 0;

	ll atoX = 0;

	priority_queue<int> mae;

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

	mae.push(-2e9);

	ato.push(2e9);

	int maeN = 0;

	int atoN = 0;

	ll B = 0;



	rep(i, Q) {

		int q;

		cin >> q;

		if (q == 1) {

			int a, b;

			cin >> a >> b;

			B += b;



			if (atoN != maeN) {

				int k = mae.top();

				if (a < k) {

					mae.pop();

					ato.push(k);

					mae.push(a);

					maeX += a - k;

					atoX += k;

				}

				else {

					ato.push(a);

					atoX += a;

				}

				atoN++;

			}

			else {

				int k = ato.top();

				if (a > k) {

					ato.pop();

					mae.push(k);

					ato.push(a);

					maeX += k;

					atoX += a - k;

				}

				else {

					mae.push(a);

					maeX += a;

				}

				maeN++;

			}

		}

		else {

			int k = mae.top();

			ll ans = (ll)maeN * k - maeX + atoX - (ll)atoN * k + B;

			cosp(k);

			co(ans);

		}

	}



	Would you please return 0;

}