#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n;
  cin >> n;
  int a[100005];
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans[100004];
  int j = 0;
  ans[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] > ans[j]) {
      ans[++j] = a[i];
    } else {
      int lo = 0, hi = j, res = 0;
      while (hi >= lo) {
        int mid = (hi + lo) / 2;
        if (ans[mid] >= a[i]) {
          res = mid;
          hi = mid - 1;
        } else
          lo = mid + 1;
      }
      ans[res] = a[i];
    }
  }
  cout << j + 1 << "\n";
  return 0;
}
