#include <iostream>
using namespace std;
int main()
{
int n,i,j;
int a[1000];
int k;//配备系统的个数
int b[1001] = {0};//每套系统最高拦截高度
int p;//拦截第i颗导弹所使用的当前系统
cin>>n;
//输入导弹高度
for(int i = 0;i < n;i++){
cin>>a[i];
}
k = 1;//第一套系统
//第一套系统最高拦截的高度是:第一颗导弹的高度
b[k] = a[0];
for(i = 1;i < n;i++){
p = 0;//假设没有系统能拦截当前的导弹
for(j = 1;j <= k;j++) {
//如果有能拦截的系统
if(b[j] >= a[i]){
//如果还没有过其他系统拦截
if(p == 0){
p = j;//第j套系统可以拦截
} else if(b[j] < b[p]){
p = j;//使用更小的消耗去拦截
}
}
}
//如果没有导弹能够拦截
if(p == 0){
k++;
b[k] = a[i];
} else{
//更新第p个拦截系统的拦截高度
b[p] = a[i];
}
}
cout<<k<<endl;
return 0;
}
/**************************************************************
Problem: 1229
User: admin
Language: C++
Result: Accepted
Time:28 ms
Memory:2072 kb
****************************************************************/