q = gets.chomp.to_i
a_arr = []
b_arr = []

q.times do
  buf = gets
  if buf[0] === '1'
    _z, a, b = buf.chomp.split.map(&:to_i)
    a_arr << a
    b_arr << b
  else
    a_size = a_arr.size
    a_arr.sort!
    b_sum = b_arr.inject(:+)
    if a_size.odd?
      x = a_arr[(a_size-1)/2]
      a_sum = 0
      a_arr.each {|e| a_sum += (e-x).abs}
      puts "#{x} #{a_sum+b_sum}"
    else
      x1 = a_arr[a_size/2 - 1]
      x2 = a_arr[a_size/2]
      a_sum1 = 0
      a_arr.each{|e| a_sum1 += (e-x1).abs}
      a_sum2 = 0
      a_arr.each{|e| a_sum2 += (e-x2).abs}
      if a_sum1 <= a_sum2
        puts "#{x1} #{a_sum1+b_sum}"
      else
        puts "#{x2} #{a_sum2+b_sum}"
      end
    end
  end
end
