#include<iostream>
using namespace std;
const int MAX=1000;
int a[MAX];
int MaxSub[MAX];
int max(int x,int y){
return x>y?x:y;
}
int MaxSubStr(int n){
int temp=MaxSub[1];
for(int i=2;i<=n;++i){
if(temp<MaxSub[i])
temp=MaxSub[i];
}
return temp;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
MaxSub[i]=1;
}
for(int i=2;i<=n;++i){
for(int j=1;j<i;++j){
if(a[i]>a[j])
MaxSub[i]=max(MaxSub[i],MaxSub[j]+1);
}
}
cout<<MaxSubStr(n)<<endl;
return 0;
}
using namespace std;
const int MAX=1000;
int a[MAX];
int MaxSub[MAX];
int max(int x,int y){
return x>y?x:y;
}
int MaxSubStr(int n){
int temp=MaxSub[1];
for(int i=2;i<=n;++i){
if(temp<MaxSub[i])
temp=MaxSub[i];
}
return temp;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
MaxSub[i]=1;
}
for(int i=2;i<=n;++i){
for(int j=1;j<i;++j){
if(a[i]>a[j])
MaxSub[i]=max(MaxSub[i],MaxSub[j]+1);
}
}
cout<<MaxSubStr(n)<<endl;
return 0;
}