#include<iostream>
#include<cstdio>
#include<set>
#include<string>
#include<string.h>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<algorithm>
#include<sstream>
#include<utility>
#include<cmath>
#include<functional>
#define mt(a) memset(a,0,sizeof (a))
#define fl(a,b,c) fill(a,b,c)
#define SWAP(a,b,t) (t=a,a=b,b=t)
#define inf 1000000000+7
using namespace std;
typedef long long ll;
int a[2000];
vector<int> vt[2000];
int main()
{
int n;
while(cin>>n)
{
for(int i = 0;i<2000;++i)
vt[i].clear();
for(int i=1;i<=n;++i)
cin>>a[i];
int ans = 0;
for(int i=1;i<=n;++i)
{
if(ans==0)
vt[++ans].push_back(a[i]);
else
{
int j;
for(j=1;j<=ans;++j)
{
if(vt[j][0] > a[i])
{
vt[j][0] = a[i];
break;
}
}
if(j>ans)
vt[++ans].push_back(a[i]);
}
}
cout<<ans<< endl;
/*mt(dp);
dp[0]=1;
for(int i=1;i<=n;i++)
{
cin>>a[i];
int minn=9999999;
for(int j=1;j<i;j++)
{
if(a[i]<a[j]&&minn>dp[j])minn=dp[j];
}
if(minn==9999999)dp[i]=dp[i-1]+1;
else dp[i]=dp[i-1];
}
cout<<dp[n]<<endl;*/
}
return 0;
}