def lenfirst(nums,i):
if i in memo.keys():
return memo[i]
if len(nums[i:]) == 1:
return 1
res = 1
for j in range(i+1,len(nums)):
if nums[i] < nums[j]:
res = max(res, lenfirst(nums, j) + 1)
memo[i] = res
return res
def lentotal(nums):
return max(lenfirst(nums, i) for i in range(len(nums)))
while True:
try:
a = input()
b = list(map(int,input().split()))
memo = {}
print(lentotal(b))
except:
break