let () = Scanf.scanf "%d\n" @@ fun n -> let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d) in let lst = List.fast_sort compare lst in let h, t = List.hd lst, List.tl lst in let ((cnt,ans),(buf,n)) = List.fold_left (fun ((cnt,ans),(buf,n)) x -> if n = x then ((cnt,ans),(buf+1,n)) else if cnt <= buf then ((buf,n),(1,x)) else ((cnt,ans),(1,x))) ((0,-1),(1,h)) t in Printf.printf "%d\n" (if cnt = buf then n else ans)