program tahort;
const
maxn=100000;
var
opt,a:array[0..maxn] of longint;
n,ans:longint;
procedure init;
var
i:longint;
begin
assign(input,'tahort.in');
reset(input);
assign(output,'tahort.out');
rewrite(output);
readln(n);
for i:=1 to n do
read(a[i]);
end;
procedure main;
var
i,j:longint;
begin
a[0]:=-maxlongint;
for i:=1 to n do
for j:=i-1 downto 0 do
if (a[j]<a[i]) and (opt[j]+1>opt[i]) then
opt[i]:=opt[j]+1;
a[n+1]:=-maxlongint;
ans:=0;
for i:=1 to n do
if opt[i]>ans then
ans:=opt[i];
end;
procedure print;
begin
writeln(ans);
close(input);
close(output);
end;
begin
init;
main;
print;
end.