import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto Q = readln.chomp.to!int;
    auto pqmin = new BinaryHeap!(Array!long, "a < b");
    auto pqmax = new BinaryHeap!(Array!long, "a > b");
    long seppen = 0;
    long left = 0;
    long right = 0;
    int cnt = 0;

    while (Q--) {
        auto s = readln.split.map!(to!long);
        if (s[0] == 1) {
            auto a = s[1];
            auto b = s[2];
            seppen += b;
            if (!pqmin.empty && a >= pqmin.front) {
                pqmax.insert(a);
                right += a;
            } else {
                pqmin.insert(a);
                left += a;
            }
            while (pqmax.length.to!int - pqmin.length.to!int > 1) {
                pqmin.insert(pqmax.front);
                left += pqmax.front;
                right -= pqmax.front;
                pqmax.removeFront;
            }
            while (pqmin.length.to!int - pqmax.length.to!int > 1) {
                pqmax.insert(pqmin.front);
                right += pqmin.front;
                left -= pqmin.front;
                pqmin.removeFront;
            }
        } else {
            long ans;
            long l = left;
            long r = right;
            long lcnt = pqmin.length.to!long;
            long rcnt = pqmax.length.to!long;
            if (pqmax.length == pqmin.length) {
                ans = pqmin.front;
                l -= pqmin.front;
                lcnt -= 1;
            } else if (pqmax.length > pqmin.length) {
                ans = pqmax.front;
                r -= pqmax.front;
                rcnt -= 1;
            } else {
                ans = pqmin.front;
                l -= pqmin.front;
                lcnt -= 1;
            }
            writeln(ans, " ", ans * lcnt - l - ans * rcnt + r + seppen);
        }
    }
}