#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
int a[MAX], t[MAX];
int main() {
  int n, i, j, ans = 1;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  t[0] = a[0], j = 0;
  for (i = 1; i < n; i++) {
    if (a[i] > t[j])
      ans++, t[++j] = a[i];
    else if (a[i] < t[0])
      t[0] = a[i];
    else
      t[lower_bound(t, t + j + 1, a[i]) - t] = a[i];
  }
  printf("%d\n", ans);
  return 0;
}
