let rec gcd m n = match m,n with | m,0 -> m | m,n -> gcd n (m mod n);;
Scanf.(Array.(scanf " %d" @@ fun n ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v)
  in print_int @@ fold_left gcd a.(0) a))