#include <bits/stdc++.h>
using namespace std;
int a[(100010) + 1];
int dp[(100010) + 1];
int main() {
  int n;
  scanf("%d", &n);
  a[0] = -1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] > a[j]) dp[i] = max(dp[i], dp[j] + 1);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i]);
  }
  printf("%d\n", ans);
  return 0;
}
