{-# LANGUAGE OverloadedStrings #-} 
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Set as S


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine
    
solve :: [(Int, Int)] -> Int -> Int
solve lrs n = let
    ls = fst <$> lrs
    rs = snd <$> lrs
    in
        max 0 $ minimum rs - maximum ls + 1


main = do
    q <- readInt
    queries <- replicateM q BC.getLine
    let accum = (0, 0, [],  0) 
    foldM (\(minx, bAccum, aList, anum) query -> 
        if query == "2" then do
            putStr $ show minx
            putStr " "
            print $ foldr (\a acc -> abs (minx - a) + acc) bAccum aList
            pure (minx, bAccum, aList, anum)
        else do
            let [_, a, b] = map (fst . fromJust . BC.readInt) . BC.words $ query
            let newANum = anum + 1
            let newAList = sort $ a:aList
            let newMinX = newAList !! ((newANum + 1) `div` 2 - 1)
            pure (newMinX, bAccum + b, a:aList, newANum)

        ) accum queries


