#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[200000+50],bj[200000+50];
int main ()
{
	int n,i;
	cin>>n;
	memset(bj,0,sizeof(bj));
	for(i=0;i<n;i++)
		cin>>a[i];
	int mx=-1;
	for(i=0;i<n;i++)
		bj[a[i]]=bj[a[i]-1]+1,mx=max(mx,bj[a[i]]);
	cout<<mx<<endl;
	return 0;
 } 