#include <bits/stdc++.h>
using namespace std;
int n, A[123457], T[4 * 123457];
int res;
int sum(int x) {
  int ans = 0;
  while (x > 0) {
    ans = ans > T[x] ? ans : T[x];
    x -= (x & -x);
  }
  return ans;
}
void up(int x, int val) {
  while (x <= n) {
    T[x] = max(T[x], val);
    x += (x & -x);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  up(A[1], 1);
  for (int i = 2; i <= n; i++) {
    int a = sum(A[i]);
    up(A[i], a + 1);
    res = res > a + 1 ? res : a + 1;
  }
  cout << res;
  return 0;
}
