#include <bits/stdc++.h>
using namespace std;
int T;
int DS[1001];
int DP[1001][1001];

int f(int i,int backed){
    int &s = DP[i][backed];
    if(i==T)return s=0;
    else if(backed!=T && DS[i]>=DS[backed])return s=f(i+1,backed);
    else return s=max(1+f(i+1,i),f(i+1,backed));

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>T;
    memset(DP,-1,sizeof(DP));
    for(int i=0;i<T;++i){

        cin>>DS[i]<<endl;

    }
    cout<<f(0,T);

    return 0;
}

