let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split(' ') |> Array.map int |> List.ofArray |> List.sort

let rec f xs =
    match xs with
        | [] -> 0
        | x::[] -> x
        | y::ys -> List.map (fun a -> a % y) ys |> Set.ofList |> Set.add y |> Set.remove 0 |> Set.toList |> List.sort |> f

f A |> printf "%d"
