#include <bits/stdc++.h>
using namespace std;
long n, m = 1;
long a[100001], b[100001];
const long INF = 1000000001;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = INF;
  }
  b[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] < b[0]) b[0] = a[i];
    for (int j = 1; j <= i; j++) {
      if (a[i] < b[j] && a[i] > b[j - 1]) {
        b[j] = a[i];
        break;
      }
    }
  }
  while (b[m] < INF) {
    m++;
  }
  cout << m << endl;
  return 0;
}
