n=int(input())
a=[0 for i in range(n)]

for i in range(n):
    a[i]=int(input())


dp=[[-1 for i in range(n+1)] for j in range(n+1)]

for i in range(n+1):
    dp[n][i]=0

i=n-1
while i>=0:
    for j in range(n+1):
        if j!=0 and a[j-1]>=a[i]:
            dp[i][j-1]=dp[i+1][j-1]
        else:
            dp[i][j-1]=max(dp[i+1][j-1],dp[i+1][i]+1)
    i-=1

sum=dp[0][n]

if sum==0:
    print(1)
else:
    print(sum)