#include <bits/stdc++.h>
using namespace std;
vector<int> a, b;
int LIS() {
  int u, v;
  b.push_back(0);
  for (int i = 1; i < a.size(); i++) {
    if (a[b.back()] < a[i]) {
      b.push_back(i);
      continue;
    }
    for (u = 0, v = b.size() - 1; u < v;) {
      int c = (u + v) / 2;
      if (a[b[c]] < a[i])
        u = c + 1;
      else
        v = c;
    }
    if (a[i] < a[b[u]]) b[u] = i;
  }
  return b.size();
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  cout << LIS() << endl;
}
