#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

#[derive(Debug)]
struct MedianHeap {
    head: std::collections::BinaryHeap<i64>,
    tail: std::collections::BinaryHeap<i64>,
    sum_head: i64,
    sum_tail: i64
}
#[derive(Debug, PartialEq, Eq)]
enum Median {
    None,
    Just(i64),
    Between(i64, i64),
}
impl MedianHeap {
    fn new() -> MedianHeap {
        MedianHeap {
            head: std::collections::BinaryHeap::new(),
            tail: std::collections::BinaryHeap::new(),
            sum_head: 0,
            sum_tail: 0,
        }
    }
    fn len(&self) -> usize {
        (self.head.len() + self.tail.len()) / 2
    }
    fn push(&mut self, x: i64) {
        match (self.head.peek(), self.tail.peek()) {
            (None, None) => {
                self.head.push(x);
                self.tail.push(-x);
                self.sum_head = x;
                self.sum_tail = x;
            },
            (Some(&a), Some(&b)) => {
                let b = -b;
                if a <= x && x <= b {
                    self.head.push(x);
                    self.tail.push(-x);
                    self.sum_head += x;
                    self.sum_tail += x;
                } else if x < a {
                    self.head.push(x);
                    self.head.push(x);
                    let _ = self.head.pop();
                    self.tail.push(-a);
                    self.sum_head += x + x;
                    self.sum_head -= a;
                    self.sum_tail += a;
                } else {
                    self.tail.push(-x);
                    self.tail.push(-x);
                    let _ = self.tail.pop();
                    self.head.push(b);
                    self.sum_tail += x + x;
                    self.sum_tail -= b;
                    self.sum_head += b;
                }
            },
            _ => {}
        }
    }
    fn peek(&self) -> Median {
        let n = self.len();
        if n == 0 {
            Median::None
        } else if n % 2 == 1 {
            Median::Just(*self.head.peek().unwrap())
        } else {
            let a = self.head.peek().unwrap();
            let b = self.tail.peek().unwrap();
            Median::Between(*a, -b)
        }
    }
}

fn main() {
    let mut sc = Scanner::new();
    let mut med = MedianHeap::new();
    let n: usize = sc.cin();
    let mut base = 0;
    for _ in 0..n {
        let ty: usize = sc.cin();
        if ty == 1 {
            let a: i64 = sc.cin();
            let b: i64 = sc.cin();
            base += b;
            med.push(a);
        } else {

            match med.peek() {
                Median::None => {},
                Median::Just(x) => {
                    // trace!(&med.head, &med.tail);
                    // trace!(&med.sum_head, &med.sum_tail);
                    let left_sum = (med.head.len() as i64 - 1) / 2 * x - (med.sum_head - x) / 2;
                    let right_sum = (med.sum_tail - x) / 2 - (med.tail.len() as i64 - 1) / 2 * x;
                    // trace!(left_sum, right_sum);
                    put!(x, base + left_sum + right_sum);
                },
                Median::Between(x, _) => {
                    // trace!(&med.head, &med.tail);
                    // trace!(&med.sum_head, &med.sum_tail);
                    let left_sum = (med.head.len() as i64) / 2 * x - med.sum_head / 2;
                    let right_sum = med.sum_tail / 2 - (med.tail.len() as i64) / 2 * x;
                    // trace!(left_sum, right_sum);
                    put!(x, base + left_sum + right_sum);
                }
            }

        }
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 10620