#include <stdio.h>
#include <string.h>
#define LEN 200
int main() {
    int val[LEN];
    int n;
    while (scanf("%d", &n) != EOF) {
        for (int i = 0; i < n; i++) {
            scanf("%d", &val[i]);
        }
        int dp[n];
        for (int i = 0; i < n; i++) {
            dp[i] = 1;
        }
        for (int i = n - 2; i >= 0; i--) {
            // printf("now i's position is %d value is %d\n", i + 1, val[i]);
            int maxstep = 1;
            for (int j = i + 1; j < n; j++) {
                // printf("now j's position is %d value is %d\n", j + 1, val[j]);
                if (val[i] < val[j]) {
                    if(maxstep < dp[j] + 1) maxstep = dp[j] + 1;
                    // printf("dp[%d] < dp[%d], %d < %d ,dp[%d]变成%d\n", i, j, val[i], val[j], i,dp[i]);
                    
                }
            }
            dp[i] = maxstep;
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (dp[i] > max) max = dp[i];
            // printf("dp[%d] is %d\n", i, dp[i]);
        }
        printf("%d\n", max);
    }
    return 0;
}