import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm, std.typecons, std.math;

void main() {
    long[] as = [];
    long B = 0;
    long q;
    readf("%d\n", &q);
    foreach (_; 0..q) {
        long a, b;
        long[] line = readln.strip.split(" ").map!(to!long).array;
        if (line.length == 3) {
            as ~= line[1];
            B += line[2];
        } else {
            long x = as[as.length/2];
            long ans = B;
            foreach (A; as) {
                ans += abs(x - A);
            }
            writefln("%d %d", x, ans);
        }
    }
}
