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

  val a2 = a1.map{ i => List(i(0) % i(1), i(1) % i(0))}
    .flatten.distinct.filter(_ != 0)
    .combinations(2).toList

  val a3 = a2.map{ i => List(i(0) % i(1), i(1) % i(0))}
    .flatten.distinct.filter(_ != 0)

  println(if (a1.size == 0) a(0) else if (a2.size == 0) a1.flatten.min else a3.min)

}
