fun main(args: Array<String>) {
    readLine()
    var a = readLine()!!.split(' ').map(String::toInt)
    var min: Int
    do {
        min = a.min()!!
        if (min == 1) break
        a = a.map { if (it == min) min else it % min }.filter { it != 0 }.distinct()
    } while (1 < a.size)
    println(min)
}
