#include <bits/stdc++.h>
int n, l[100000], i, j, dp[100000], r = 0;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &l[i]);
  for (i = 0; i < n; i++)
    for (dp[i] = 1, j = 0; j<i; r = (r)>(dp[i]) ? r : dp[i], j++)
      if (l[j] < l[i]) dp[i] = (dp[i]) > (dp[j] + 1) ? dp[i] : dp[j] + 1;
  printf("%d\n", r);
  return 0;
}
