### BUGGY CODE ###

import numpy as np
import heapq
Q = int(input())
Qlist = [list(map(int,input().split())) for i in range(Q)]
#print(Qlist)
coef_list = []
intercept = [0]
left_list = []
cent_list = []
right_list = []
left_sum = [0]
right_sum = [0]

median = [0]
count = [0,0]

def update_func(query):
    source = query[1]
    coef_list.append(query[1])
    intercept[0] += query[2]

    if len(coef_list) == 1:
        cent_list.append(source)
        median[0] = cent_list[0]
        return
    if cent_list == []:
        if median[0] > source:
            heapq.heappush(left_list, -source)
            left_sum[0] += source #
            tmp = -heapq.heappop(left_list)
            left_sum[0] -= tmp #
            cent_list.append(tmp)
        elif right_list[0] > source:
            cent_list.append(source)
        else:
            heapq.heappush(right_list, source)
            tmp = heapq.heappop(right_list)
            right_sum[0] += source - tmp
            cent_list.append(tmp)
        median[0] = cent_list[0]
    else:
        if cent_list[0] < source:
            heapq.heappush(left_list, -cent_list[0])
            count[0] += 1
            left_sum[0] += cent_list[0]
            median[0] = cent_list[0]
            heapq.heappush(right_list, source)
            count[1] += 1
            right_sum[0] += source
            cent_list.remove(cent_list[0])
        else:
            heapq.heappush(left_list, -source)
            left_sum[0] += source
            count[0] += 1
            median[0] = -left_list[0]
            heapq.heappush(right_list, cent_list[0])
            count[1] += 1
            right_sum[0] += cent_list[0]
            cent_list.remove(cent_list[0])
    return
def solve_func():
    cent = 0
    if cent_list != []:
        cent = cent_list[0]
    minval = np.abs(left_sum[0]-count[0]*median[0]) + np.abs(right_sum[0]-count[1]*median[0])
    minval += intercept[0]
    print(str(median[0]) + " " + str(minval))

for query in Qlist:
    if query[0] == 1:
        update_func(query)
    else:
        solve_func()


### FIXED CODE ###

import numpy as np
import heapq
Q = int(input())
Qinit = list(map(int,input().split()))
Qlist = [list(map(int,input().split())) for i in range(Q-1)]

#coef_list = []
intercept = Qinit[2]
left_list = []
cent_list = [Qinit[1]]
right_list = []
left_sum = 0
right_sum = 0

median = Qinit[1]
count = 0

for query in Qlist:
    if query[0] == 1:
        source = query[1]
        intercept += query[2]

        if cent_list == []:
            if median > source:
                heapq.heappush(left_list, -source)
                left_sum += source #
                tmp = -heapq.heappop(left_list)
                left_sum -= tmp #
                cent_list.append(tmp)
            elif right_list[0] > source:
                cent_list.append(source)
            else:
                heapq.heappush(right_list, source)
                tmp = heapq.heappop(right_list)
                right_sum += source - tmp
                cent_list.append(tmp)
            median = cent_list[0]
        else:
            if cent_list[0] < source:
                heapq.heappush(left_list, -cent_list[0])
                left_sum += cent_list[0]
                median = cent_list[0]
                heapq.heappush(right_list, source)
                right_sum += source
                cent_list.remove(cent_list[0])
            else:
                heapq.heappush(left_list, -source)
                left_sum += source
                median = -left_list[0]
                heapq.heappush(right_list, cent_list[0])
                right_sum += cent_list[0]
                cent_list.remove(cent_list[0])
            count += 1

    else:
        minval = np.abs(left_sum-count*median) + np.abs(right_sum-count*median) + intercept
        #print(str(median) + " " + str(minval))
        print("{} {}".format(median, minval))