let rec gcd a b =
  if b = 0 then
    a
  else
    gcd b (a mod b)

let id x = x

let make_list f =
  let rec loop acc = function
    | 0 -> List.rev acc
    | n -> loop (f () :: acc) (n - 1)
  in
  loop

let n =
  Scanf.scanf "%d\n" id
let lst =
  make_list (fun () -> Scanf.scanf "%d " id) [] n
let result =
  List.fold_left gcd 0 lst

let () =
  Printf.printf "%d\n" result
