#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<class T> class Treap {
protected:
    mt19937 random;
    T ie;
    function<T(T, T)> f;

    struct Node {
        T value;
        T sum;
        size_t size;
        size_t priority;
        Node* l = nullptr;
        Node* r = nullptr;

        Node(T value, size_t priority) : value(value), priority(priority) {}
    };
    Node* root;

    inline int size(Node* node) { return node ? node->size : 0; }
    inline T sum(Node* node) { return node ? node->sum : ie; }

    void update(Node* node) {
        if(node) {
            node->size = 1 + size(node->l) + size(node->r);
            node->sum = f(node->value, f(sum(node->l), sum(node->r)));
        }
    }

    // [0, l) + [0, r) -> [0, l+r)
    void merge(Node* l, Node* r, Node* &node) {
        if(!l || !r) {
            node = l ? l : r;
        } else if(l->priority < r->priority) {
            node = r;
            merge(l, r->l, r->l);
        } else {
            node = l;
            merge(l->r, r, l->r);
        }
        update(node);
    }

    // [0, n) -> [0, i), [i, n)
    void split(Node* node, int i, Node* &l, Node* &r) {
        if(!node) {
            l = r = nullptr;
        } else if(size(node->l) < i) {
            split(node->r, i - size(node->l) - 1, node->r, r);
            l = node;
        } else {
            split(node->l, i, l, node->l);
            r = node;
        }
        update(node);
    }

    // [0, i) + (value) + [i, n)
    void insert(Node* &node, int i, T value) {
        Node *l, *r;
        split(node, i, l, r);
        merge(l, new Node(value, random()), l);
        merge(l, r, node);
    }

    // [0, n) -> [0, i) + [i+1, n)
    void erase(Node* &node, int i) {
        Node *l, *r, *_;
        split(node, i, l, r);
        split(r, 1, _, r);
        merge(l, r, node);
    }

    // debug
    void print(Node* node) {
        if (!node) return;
        print(node->l);
        cout << node->value << " ";
        print(node->r);
    }

public:
    Treap(T ie=0, function<T(T, T)> f=plus<T>(), Node* node=nullptr) : ie(ie), f(f), root(node) {
        random = mt19937((int)random_device()());
    }

    // this + right
    Treap merge(Treap right) {
        merge(root, right.root, root);
        return *this;
    }

    // [0, n) -> [0, i), [i, n)
    pair<Treap, Treap> split(int i) {
        Node *l, *r;
        split(root, i, l, r);
        return {Treap(ie, f, l), Treap(ie, f, r)};
    }

    // [0, n) -> [0, i) + [i+1, n)
    void erase(int i) {
        erase(root, i);
    }

    // [0, i) + (value) + [i, n)
    void insert(int i, T value) {
        insert(root, i, value);
    }

    // sum [l, r)
    T query(int left, int right) {
        Node *t1, *t2, *t3;
        split(root, left, t1, t2);
        split(t2, right - left, t2, t3);
        T res = sum(t2);
        merge(t1, t2, root);
        merge(root, t3, root);
        return res;
    }

    T operator[](int i) {
        return query(i, i+1);
    }

    int size() {
        return size(root);
    }

    // debug
    void print() {
        cout << "{ ";
        print(root);
        cout << "}" << endl;
    }
};

template<class T> class sorted_vector : public Treap<T> {
    using Node = typename Treap<T>::Node;

    int lower_bound(Node* node, T value) {
        if(!node) {
            return 0;
        } else if(node->value >= value) {
            return lower_bound(node->l, value);
        } else {
            return lower_bound(node->r, value) + this->size(node->l) + 1;
        }
    }

    int upper_bound(Node* node, T value) {
        if(!node) {
            return 0;
        } else if(node->value <= value) {
            return upper_bound(node->r, value) + this->size(node->l) + 1;
        } else {
            return upper_bound(node->l, value);
        }
    }

public:
    sorted_vector(T ie=0, function<T(T, T)> f=plus<T>()) : Treap<T>(ie, f) {}

    int lower_bound(T value) {
        return lower_bound(this->root, value);
    }

    int upper_bound(T value) {
        return upper_bound(this->root, value);
    }

    void push(T value) {
        this->insert(lower_bound(value), value);
    }
};

int main() {
    sorted_vector<lint> sv;

    lint q;
    cin >> q;

    lint bsum = 0;
    while(q--) {
        lint t;
        cin >> t;

        if(t == 1) {
            lint a, b;
            cin >> a >> b;
            sv.push(a);
            bsum += b;
        }

        if(t == 2) {
            lint n = sv.size();
            lint mid = (n-1)/2;
            lint med = sv[mid];

            lint before = med * (mid - 0) - sv.query(0, mid);
            lint after = sv.query(mid, n) - med * (n - mid);
            cout << med << " " << before + after + bsum << endl;
        }
    }
}

Measured memory_bytes: 12800