fun main(args: Array<String>) {
    val A = mutableListOf<Int>()
    for (i in 0 until readLine()!!.toInt()) {
        val p = readLine()!!.split(" ").map { n -> n.toInt() }.toMutableList()
        when (p[0]) {
            0 -> A.add(p[1])
            1 -> println(A[p[1]])
            2 -> A.removeAt(A.lastIndex)
        }
    }
}
