open Printf
open Scanf

let n = sscanf (read_line ()) "%d" (fun n -> n);;
let array = Array.make n 0;;
Array.iteri (fun x _ -> array.(x) <- read_int()) array;;

let list_update list num =
let rec loop now =
match now with
| [] -> [num]
| x::rest ->
    if num < x then
        num::rest
    else
        x :: (loop rest)
in loop list;;

let rec solve n list =
    if n < 0 then List.length list
    else 
        let l = list_update list (array.(n)) in
        solve (n-1) l;;

printf ("%d\n") (solve (n-1) []);;