object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val a = Array.fill(n)(sc.nextInt).combinations(2).toList

  val ans = a.map{ i =>
    val mod1 = i(1) % i(0)
    val mod2 = i(0) % i(1)
    if (mod1 == 0 || mod2 == 0) i.min
    else {
      val mod3 = mod1 % mod2
      val mod4 = mod2 % mod1
      if (mod3 == 0 || mod4 == 0) math.min(mod1, mod2)
      else math.min(mod3, mod4)
    }
  }.min

  println(ans)
}
