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

    println(aa.fold(aa[0], { acc, a -> gcd(acc, a)}))
}

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