#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct Compress {
  vector<T> xs;

  Compress() = default;

  Compress(const vector<T> &vs) {
    add(vs);
  }

  Compress(const initializer_list<vector<T>> &vs) {
    for(auto &p : vs) add(p);
  }

  void add(const vector<T> &vs) {
    copy(begin(vs), end(vs), back_inserter(xs));
  }

  void add(const T &x) {
    xs.emplace_back(x);
  }

  void build() {
    sort(begin(xs), end(xs));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
  }

  vector<int> get(const vector<T> &vs) const {
    vector<int> ret;
    transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
      return lower_bound(begin(xs), end(xs), x) - begin(xs);
    });
    return ret;
  }

  int get(const T &x) const {
    return lower_bound(begin(xs), end(xs), x) - begin(xs);
  }

  const T &operator[](int k) const {
    return xs[k];
  }
};

template<typename T>
struct BinaryIndexedTree {
    int N;
    vector<T> data;

    BinaryIndexedTree(int sz) {
        N = sz;
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for(; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    T sum(int l, int r) {
        T vl = sum(l);
        T vr = sum(r);
        return vr - vl;
    }

    void add(int k, T x) {
        for(++k; k < data.size(); k += k & -k) data[k] += x;
    }

    int lowerbound(int x) {
        int k = 1;
        int res = 0;
        while ((k<<1) <= N) k <<= 1;
        while (k > 0) {
            if (res + k <= N && data[res+k] < x) {
                x -= data[res+k];
                res += k;
            }
            k >>= 1;
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int Q; cin >> Q;
    vector<tuple<int, ll, ll>> W(Q);
    vector<ll> V;
    rep(i,Q) {
        int com; cin >> com;
        if (com==1) {
            ll a,b; cin >> a >> b;
            V.emplace_back(a);
            W[i] = make_tuple(com,a,b);
        } else W[i] = make_tuple(com,-1,-1);
    }

    Compress<ll> C(V);
    C.build();
    auto CV = C.get(V);
    int N = C.xs.size();
    BinaryIndexedTree<ll> bitcnt(N),bitl(N),bitr(N);
    ll num = 0;
    int k;
    ll B = 0;
    ll val;
    rep(i,Q) {
        ll com,a,b;
        tie(com,a,b) = W[i];
        if (com==1) {
            B += b;
            bitcnt.add(CV[num],1);

            k = bitcnt.lowerbound(num/2+1);
            val = C[k];
            bitl.add(CV[num],-V[num]);
            bitr.add(CV[num],V[num]);
            num++;
        } else {
            ll m = (num+1)/2;
            ll ans = 0;
            ans += bitl.sum(k) + bitcnt.sum(k)*val;
            ans += bitr.sum(k,N) - bitcnt.sum(k,N)*val;
            ans += B;
            cout << val << " " << ans << endl;
        }
    }
}

Measured memory_bytes: 12148