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