#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
#include <sstream>
#include <map>
#define F first
#define S second
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
typedef pair<double, double> pdd;
typedef pair<short,short> pii;
const double EPS = 10e-6;
vector<int> a;
map<pii,short> memo;
short dp(short now,short p)
{
	if(now==a.size())return 0;
	if(memo.count(pii(now,p)))return memo[pii(now,p)];
	int ans =0;
	if(a[now]>a[p])
	{
		ans=max(dp(now+1,now)+1,dp(now+1,p));
	}else ans=dp(now+1,p);

	return memo[pii(now,p)]=ans;

}

int main ()
{
	int n;
	cin>>n;
	a.push_back(-1);
	rep(i,n)
	{
		int x;
		cin>>x;
		a.push_back(x);
	}
	cout<<dp(0,0)<<endl;



}