#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
vector<int>memo(5003,-1);
int dfs(int pos,vector<int>&nums){
int n = nums.size() - 1;
if(memo[pos] != -1) return memo[pos];
if(pos == n) return memo[n] = 1;
int tmax = 0;
for( int j = pos + 1;j <= n;j++){
if(nums[j] > nums[pos])
tmax = max(tmax,dfs(j,nums));
}
return memo[pos] = tmax+1;
}
int main(){
int n;
cin >> n;
vector<int>nums(n+1);
for(int i = 1;i <= n;i++){
cin >> nums[i];
}
cout << dfs(1,nums) << endl;
return 0;
}