import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] dp = new int[n];
		int[] a = new int[n];
		for(int i = 0; i < n; i++)a[i] = in.nextInt();
		Arrays.fill(dp, 1);
		int maxLen = 1;
		for(int i = 1; i < n; i++) {
			for(int j = 0; j < i; j++) {
				if(a[j] < a[i])dp[i] = Math.max(dp[i], dp[j] + 1);
			}
			maxLen = Math.max(maxLen, dp[i]);
		}
		System.out.println(maxLen);
	}
}

一维dp,但是时间复杂度为O(n^2),因为是求子序列,所以要和当前数的前面的所有数进行比较