fun main(args: Array<String>){
    readLine()
    val input: MutableList<Int> = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var min: Int
    var firstMinSwitch: Boolean

    while(true) {
        firstMinSwitch = true

        if(input.size == 1) break

        min = input.min()!!

        for(i in 0 until input.size){
            if (input[i] == min){
                if(firstMinSwitch){
                    firstMinSwitch = false
                }else{
                    input[i] = 0
                }
            }else{
                input[i] %= min
            }
        }

        input.removeAll{it == 0}

    }

    println(input[0])
}