#include <bits/stdc++.h>
using namespace std;
int main() {
  int s[100005];
  int a;
  scanf("%d", &a);
  fill(s, s + a + 3, 1 << 29);
  int b;
  for (int c = 0; c < a; c++) {
    scanf("%d", &b);
    auto x = lower_bound(s, s + a + 1, b);
    *x = b;
  }
  for (int q = 0; q < a + 3; q++) {
    if (s[q] == 1 << 29) {
      printf("%d\n", q);
      break;
    }
  }
}
