n = gets.to_i
query = Array.new(n).map{Array.new(2,0)}
n.times{|i| query[i] = gets.split.map(&:to_i)}
func_a = []
func_b = 0
for i in 0..n-1
  if query[i][0] == 1
    func_a.push(query[i][1])
    func_b += query[i][2]
  else
    count = 0
    func_a.sort!
    print func_a[((func_a.length+1)/2)-1]
    print " "
    func_a.length.times{|i|count += (func_a[i] - func_a[((func_a.length+1)/2)-1]).abs}
    print count+func_b
    print "\n"
  end
end
