#include <bits/stdc++.h>
using namespace std;
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] = (((dp[i]) > (dp[j] + 1)) ? (dp[i]) : (dp[j] + 1));
      }
    }
    if (!dp[i]) dp[i] = 1;
    ans = (((ans) > (dp[i])) ? (ans) : (dp[i]));
  }
  printf("%d\n", ans);
}
