

fun main(args:Array<String>):Unit {
    val vector = Vector()
    repeat(readLine()!!.toInt()){
        val arg = readLine()!!.split(' ').map(String::toInt)
        when(arg.first()){
            0 -> vector.pushBack(arg.last())
            1 -> println(vector[arg.last()])
            else -> vector.popBack()
        }
    }
}

class Vector {
    var capacity:Int = 100
        private set
    var size:Int = 0
        private set
    private var mArray:Array<Int> = Array(100){0}
    fun pushBack(value:Int):Unit  {
        if (size == capacity){
            capacity *= 2
            val newArray = Array(capacity * 2){0}
            mArray.forEachIndexed{
                index, v-> newArray[index] = v
            }
            mArray = newArray
        }
        mArray[size++] = value
    }
    fun popBack():Unit { --size}
    operator fun get(index:Int):Int = mArray[index]
}
