#include <bits/stdc++.h>
using namespace std;
int N;
int dp[1010];
int a[1010];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
  }
  dp[1] = a[1];
  int len = 1;
  for (int i = 2; i <= N; i++) {
    if (dp[len] <= a[i]) {
      len += 1;
      dp[len] = a[i];
    } else {
      int pos = lower_bound(dp + 1, dp + len + 1, a[i]) - dp;
      dp[pos] = a[i];
    }
  }
  printf("%d\n", len);
  return 0;
}
