#include <bits/stdc++.h>
using namespace std;
int N;
int A[100002], D[100002];
int result;
int AIB[100002];
void update(int pos, int val) {
  for (; pos <= 100000; pos += pos & -pos) AIB[pos] = max(AIB[pos], val);
}
int query(int pos) {
  int resnow = 0;
  for (; pos >= 1; pos -= pos & -pos) resnow = max(resnow, AIB[pos]);
  return resnow;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];
  for (int i = 1; i <= N; ++i) {
    D[i] = query(A[i] - 1) + 1;
    update(A[i], D[i]);
    result = max(result, D[i]);
  }
  cout << result << '\n';
}
