import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val HPs = List.fill(N)(sc.nextInt()).sortWith((a, b) => a < b)

    def updateHPs(small: Int, big: Int): Int = {
      val ret = big - small
      if (ret > 0) {
        if (ret > small) updateHPs(small, ret) else updateHPs(ret, small)
      } else small
    }
    println(updateHPs(HPs(0), HPs(1)))
  }
}
