def func(alist,blist,asum,q)
  alist_sort = alist.sort
  seti =  (q.to_f/2.to_f).ceil
  x = alist_sort[seti]
  ans = 0
  1.upto(alist_sort.size-1) do |i|
    ans +=  (x - alist_sort[i]).abs
  end
  ans += blist[-1]
  return [x,ans]
end


q = gets.chomp.to_i
result = []
fx = 0

asum = 0
alist = [0]
blist = [0]
result = []
asize = 0
q.times do |i|
  flag,a,b = gets.chomp.split.collect{ |item| item.to_i}
  if flag == 1
    asize += 1
    asum += a
    alist.push(a)
    blist.push(blist[-1]+b)
  else
    result.push(func(alist,blist,asum,asize))
  end
end

result.each do |one|
  puts one.join(" ")
end