let run_benchmark : int -> int = fun _ : int ->
    let size : int = read_int () in
    let a : vec[int] = vector size 1 in

    let rec sort : vec[int] -> int -> int -> int =
        fun (a : vec[int]) (p : int) (r : int) ->
            if p < r then
                let q : int = partition a p r in
                sort a p (q - 1) ;
                sort a (q + 1) r
            else
                0

    and partition : vec[int] -> int -> int -> int =
        fun (a : vec[int]) (p : int) (r : int) ->
            let i : vec[int] = (vector 1 (p - 1)) in
            let x : int = vector_get a r in
            (for j = p to r do
                if (vector_get a j) <= x then
                    vector_set i 0 ((vector_get i 0) + 1) ;
                    swap a (vector_get i 0) j
                else
                    0
            done) ;
            (swap a ((vector_get i 0) + 1) r) ;
            ((vector_get i 0) + 1)

    and swap : vec[int] -> int -> int -> int =
        fun (a : vec[int]) (i : int) (j : int) ->
            if i = j then
                0
            else
                let t : int = vector_get a i in
                vector_set a i (vector_get a j) ;
                vector_set a j t ;
                0
    in

    for i = 0 to size do
        vector_set a i (read_int ())
    done ;
    sort a 0 (size - 1) ;
    print_int (vector_get a (size - 1)) ;
    0
in
time run_benchmark
