q_num = gets.chomp.split(" ").map {|item| item.to_i }
f_num = 0
a_list = []
b_sum = 0
q_num.times do |i|
    query, a, b = gets.chomp.split(" ").map {|item| item.to_i }.sort!
    if query == 1
        a_list[f_num] = a
        b_sum += b
        f_num += 1
    else
        avg = a_list.inject(0.0){|r,i| r+=i }/a_list.size
        sum = 0
        a_list.each do |a|
            sum += (a - avg).abs
        end
        sum += b_sum
        puts sum
    end
end