#include <bits/stdc++.h>
using namespace std;
static vector<uint32_t> arr;
static vector<uint32_t> l;
int32_t main() {
  uint32_t n;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    arr.push_back(val);
  }
  l.push_back(arr[0]);
  for (uint32_t i = 1; i < arr.size(); i++) {
    if (l[l.size() - 1] < arr[i]) {
      l.push_back(arr[i]);
    } else {
      uint32_t at = upper_bound(l.begin(), l.end(), arr[i]) - l.begin();
      l[at] = arr[i];
    }
  }
  cout << l.size() << endl;
  return 0;
}
