Q = gets.to_i
query = []
Q.times{|q|
  query << gets.chomp.split(" ").map(&:to_i);
}

a = []
b = 0
query.each{|q|
  if q[0] == 1 then
    a << q[1]
    b += q[2]
  else
    a.sort!
    m = (a.size - 1) / 2
    l = m > 0 ? a[0...m].inject(:+) : 0
    r = a.size > 1 ? a[m + 1...a.size].inject(:+) : 0
    if a.size.even? then
      printf("#{a[m]} #{r - l - a[m] + b}\n")
    else
      printf("#{a[m]} #{r - l + b}\n")
    end
  end
}
