/*
 * Contents   : AOJ DPL 1 D 
 * Author     : KitauraHiromi
 * LastUpdate : 20180613
 * Since      : 20180613
 */
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int N;
int dp[100001]; // dp[i]: i番目までの文字を見たときのLIS
int a[100001];
int main(void){
    cin >> N;
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<N; ++i) cin >> a[i];
    for(int i=0; i<N; ++i){
        for(int j=0; j<N; ++j){
            (a[j] < a[i]) ? dp[i] = max(dp[j] + 1, dp[i]);
        }
    }
    cout << dp[N] << endl;
}
