#include <bits/stdc++.h>
using namespace std;
int n, aib[100002];
inline int query(int pos) {
  int ans = 0;
  for (; pos > 0; pos -= (pos & (-pos))) ans = max(ans, aib[pos]);
  return ans;
}
inline void update(int pos, int val) {
  for (; pos <= n; pos += (pos & (-pos))) aib[pos] = max(aib[pos], val);
}
int main() {
  int answer = 0, best, i, x;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &x);
    best = query(x - 1) + 1;
    answer = max(answer, best);
    update(x, best);
  }
  printf("%d", answer);
  return 0;
}
