#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

using namespace std;
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define if_range(x, w, h) if (w <= x && x <= h)
#define BitCheck(a,b)   (a >> b) & 1
#define BitSet(a,b)       a |= (1 << b)
#define BitunSet(a,b)    a &= ~(1 << b)
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define numof(array)  (sizeof (array) / sizeof *(array))

long long int a[100000];
int  n, dp[100001], ans;

int main() {
	scanf("%d", &n);
	for (int i = 0; n > i; i++)
		scanf("%lld", &a[i]);

	for (int i = 0; n > i; i++) {
		for (int j = 0; i > j; j++) {
			if (a[j] < a[i]){
				if (dp[j] == ans) {
					dp[i] = ans;
					break;
				}
				dp[i] = max(dp[i], dp[j] + 1);
		}
		if (!dp[i])dp[i] = 1;
		ans = max(ans, dp[i]);
	}
	printf("%d\n", ans);
}