import java.util.*

fun main(args : Array<String>) {
    val Q = readLine()!!.toInt()

    val A = MedianManager(Q)
    var B = 0L
    // o(QlogQ)
    (1..Q).forEach {
        val query = readLine()!!
        if (query[0] == '1') {
            val (q, a, b) = query.split(" ").map { it.toLong() }
            // Should be O(logQ)
            A.add(a)
            B += b
        } else {
            // 求める
            // fx = sum(|x - ai|) + B
            // sum(|x -ai|)の最小値をとるx はai の中央値
            // Should be O(log1)
            val median = A.median()
            var sum = A.rightSum - A.leftSum + B
            if (!A.isBalanced()) {
                sum -= median
            }
            println(median.toString() + " " + sum.toString())
        }
    }
}

class MedianManager(size: Int) {
    private var leftPriorityQueue: PriorityQueue<Long> = PriorityQueue(size, Collections.reverseOrder())
    var leftSum = 0L
    private var rightPriorityQueue: PriorityQueue<Long> = PriorityQueue(size)
    var rightSum = 0L

    fun add(element: Long) {
        // Add element so that left.size <= right.size will be kept.
        if (leftPriorityQueue.size < rightPriorityQueue.size) {
            leftPriorityQueue.add(element)
            leftSum += element
        } else {
            rightPriorityQueue.add(element)
            rightSum += element
        }

        if (leftPriorityQueue.size == 0 || rightPriorityQueue.size == 0) {
            return
        }

        if (leftPriorityQueue.peek() > rightPriorityQueue.peek()) {
            val greaterElement = leftPriorityQueue.poll()
            leftSum -= greaterElement
            val smallerElement = rightPriorityQueue.poll()
            rightSum -= smallerElement


            rightPriorityQueue.add(greaterElement)
            rightSum += greaterElement

            leftPriorityQueue.add(smallerElement)
            leftSum += smallerElement
        }
    }

    fun median() : Long {
        if (leftPriorityQueue.size < rightPriorityQueue.size || leftPriorityQueue.size == 0) {
            return rightPriorityQueue.peek()
        }

        return leftPriorityQueue.peek()
        //return (leftPriorityQueue.peek() + rightPriorityQueue.peek()) / 2
    }

    fun isBalanced() : Boolean {
        return leftPriorityQueue.size == rightPriorityQueue.size
    }
}