import sys

stdin = sys.stdin



sys.setrecursionlimit(10 ** 7)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x) - 1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())





from heapq import heappush, heappop





# 中央値以上と以下をheapで管理

upper_asc = []

lower_dsc = []



q = ni()

ans = 0



for i in range(q):

    query = list(map(int, ns().split()))

    if query[0] == 1:

        a, b = query[1], query[2]

        heappush(upper_asc, a)

        heappush(lower_dsc, -a)



        if i == 0:

            ans += b

            continue



        x, y = heappop(upper_asc), -heappop(lower_dsc)



        ans += (y - x) + b



        heappush(upper_asc, y)

        heappush(lower_dsc, -x)



    else:

        print((-lower_dsc[0], ans))



import sys

stdin = sys.stdin



sys.setrecursionlimit(10 ** 7)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x) - 1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from heapq import heappop, heappush



bigger = []

smaller = []



def modify(bigger, smaller, a: int, b: int, mid: int, ans: int):

    if not bigger and not smaller:

        heappush(smaller, -a)

        mid = a

    elif not bigger:

        if a < -smaller[0]:

            heappush(bigger, -heappop(smaller))

            heappush(smaller, -a)



            ans += abs(-smaller[0] - mid)



        else:

            heappush(bigger, a)

    else:

        if a < -smaller[0]:

            tmp = -heappop(smaller)

            heappush(smaller, -a)

            if (len(smaller) + len(bigger)) % 2:

                ans += abs(-smaller[0] - mid)

        elif a > bigger[0]:

            tmp = heappop(bigger)

            heappush(bigger, a)

        else:

            tmp = a



        if len(smaller) == len(bigger):

            heappush(smaller, -tmp)

        else:

            heappush(bigger, tmp)



    ans += (abs(-smaller[0] - a) + b)

    mid = -smaller[0]



    return mid, ans



q = ni()

mid = ans = 0



for _ in range(q):

    # judge process

    query = ns()

    if query.startswith("1"):

        _, a, b = list(map(int, query.split()))

        mid, ans = modify(bigger, smaller, a, b, mid, ans)



    else:

        print((mid, ans))
import sys

stdin = sys.stdin
sys.setrecursionlimit(10**7)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from heapq import heappush, heappop

# 中央値以上と以下をheapで管理
upper_asc = []
lower_dsc = []
q = ni()
ans = 0
for i in range(q):
    query = list(map(int, ns().split()))
    if query[0] == 1:
        a, b = query[1], query[2]
        heappush(upper_asc, a)
        heappush(lower_dsc, -a)
        if i == 0:
            ans += b
            continue
        x, y = heappop(upper_asc), -heappop(lower_dsc)
        ans += (y - x) + b
        heappush(upper_asc, y)
        heappush(lower_dsc, -x)
    else:
        print((-lower_dsc[0], ans))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**7)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from heapq import heappop, heappush

bigger = []
smaller = []


def modify(bigger, smaller, a: int, b: int, mid: int, ans: int):
    if not bigger and not smaller:
        heappush(smaller, -a)
        mid = a
    elif not bigger:
        if a < -smaller[0]:
            heappush(bigger, -heappop(smaller))
            heappush(smaller, -a)
            ans += abs(-smaller[0] - mid)
        else:
            heappush(bigger, a)
    else:
        if a < -smaller[0]:
            tmp = -heappop(smaller)
            heappush(smaller, -a)
            if (len(smaller) + len(bigger)) % 2:
                ans += abs(-smaller[0] - mid)
        elif a > bigger[0]:
            tmp = heappop(bigger)
            heappush(bigger, a)
        else:
            tmp = a
        if len(smaller) == len(bigger):
            heappush(smaller, -tmp)
        else:
            heappush(bigger, tmp)
    ans += abs(-smaller[0] - a) + b
    mid = -smaller[0]
    return mid, ans


q = ni()
mid = ans = 0
for _ in range(q):
    # judge process
    query = ns()
    if query.startswith("1"):
        _, a, b = list(map(int, query.split()))
        mid, ans = modify(bigger, smaller, a, b, mid, ans)
    else:
        print((mid, ans))

-from heapq import heappush, heappop +from heapq import heappop, heappush -# 中央値以上と以下をheapで管理 -upper_asc = [] -lower_dsc = [] +bigger = [] +smaller = [] + + +def modify(bigger, smaller, a: int, b: int, mid: int, ans: int): +    if not bigger and not smaller: +        heappush(smaller, -a) +        mid = a +    elif not bigger: +        if a < -smaller[0]: +            heappush(bigger, -heappop(smaller)) +            heappush(smaller, -a) +            ans += abs(-smaller[0] - mid) +        else: +            heappush(bigger, a) +    else: +        if a < -smaller[0]: +            tmp = -heappop(smaller) +            heappush(smaller, -a) +            if (len(smaller) + len(bigger)) % 2: +                ans += abs(-smaller[0] - mid) +        elif a > bigger[0]: +            tmp = heappop(bigger) +            heappush(bigger, a) +        else: +            tmp = a +        if len(smaller) == len(bigger): +            heappush(smaller, -tmp) +        else: +            heappush(bigger, tmp) +    ans += abs(-smaller[0] - a) + b +    mid = -smaller[0] +    return mid, ans + + -ans = 0 -for i in range(q): -    query = list(map(int, ns().split())) -    if query[0] == 1: -        a, b = query[1], query[2] -        heappush(upper_asc, a) -        heappush(lower_dsc, -a) -        if i == 0: -            ans += b -            continue -        x, y = heappop(upper_asc), -heappop(lower_dsc) -        ans += (y - x) + b -        heappush(upper_asc, y) -        heappush(lower_dsc, -x) +mid = ans = 0 +for _ in range(q): +    # judge process +    query = ns() +    if query.startswith("1"): +        _, a, b = list(map(int, query.split())) +        mid, ans = modify(bigger, smaller, a, b, mid, ans) -        print((-lower_dsc[0], ans)) +        print((mid, ans))