import heapq as h

# Lingest Increasing Subsequence
# Given input: the length of the sequence followed by the sequence
def LIS():
    length = int(input())
    sequence = []
    for i in range(length):
        sequence.append(int(input()))
    
    L = []
    for i in range(length):
        temp = [0]
        for j in range(0, i):
            if sequence[j] < sequence[i]:
                h.heappush(temp, -L[j])
        L.append(1 - temp[0])
    return max(L)

if __name__ == '__main__':
     print(LIS())