//POJ 2533 n^2 版
#include "stdio.h"
#include "queue"
#include "math.h"
using namespace std;
const int maxn = 1005;
int n;
int num[maxn],d[maxn];
int main()
{
//freopen("data.in","r",stdin);
scanf("%d",&n);
for( int i = 1; i <= n; i ++ )
{
scanf("%d",&num[i]);
}
int maxs = 0;
for( int i = 1; i <= n; i ++ )
{
d[i] = 1;
for( int j = 1; j <= i-1; j ++ )
{
if( num[j] < num[i] && d[i] < d[j] + 1 )
{
d[i] = d[j] + 1;
}
}
if( d[i] > maxs )
maxs = d[i];
}
printf("%d\n",maxs);
return 0;
}
#include <stdio.h>
#include <string.h>
#include <queue>
using namespace std;
const int maxn = 1005;
int n;
int stack[maxn];
int main()
{
int temp,top = 0;
scanf("%d",&n);
stack[0] = -1;
for( int i = 1; i <= n; i ++ )
{
scanf("%d",&temp);
if( temp > stack[top] )
stack[++top] = temp;
else
{
int ld = 1, rd = top, mid;
while( ld <= rd )
{
mid = ( ld+rd )/2;
if( temp > stack[mid] )
ld = mid + 1;
else
rd = mid - 1;
}
stack[ld] = temp;
}
}
printf("%d\n",top);
return 0;
}