#!/usr/bin/env python3

# université pierre et marie curie - c. dürr - 2017
# http://www-desir.lip6.fr/~durrc/Iut/cpa/2017/tme5-progdyn/

# Plus longue sous-séquence croissante
# algorithme: prod-dyn sur une grille avec recherche dichotomique
# complexité: O(n log m) n = entrée, m = sortie
# http://pythonhosted.org/tryalgo/_modules/tryalgo/longest_increasing_subsequence.html

from sys import stdin
from tryalgo.longest_increasing_subsequence import longest_increasing_subsequence

def readint():
    return int(stdin.readline())

def readints():
    return map(int, stdin.readline().split())

n = readint()
x = [readint() for _ in range(n)]
print(len(longest_increasing_subsequence(x)))
