fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }

    val res = A.reduce { acc, i -> gcd(acc, i) }
    println(res)
}

fun gcd(a: Int, b: Int) : Int {
    if (b == 0) {
        return a
    }

    return gcd(b, a % b)
}

