#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[100010];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v;
  v.push_back(a[0]);
  for (int i = 1; i < n; i++) {
    if (a[i] > v.back()) {
      v.push_back(a[i]);
    } else {
      int x = int(upper_bound(v.begin(), v.end(), a[i]) - v.begin());
      v[x] = a[i];
    }
  }
  cout << v.size() << endl;
  return 0;
}
