#include <bits/stdc++.h>
using namespace std;
int N, i, ANS;
int A[100010];
int AIB[4 * 100010];
void update(int p, int v) {
  for (; p <= N; p += (p & (-p))) AIB[p] = max(AIB[p], v);
}
int query(int p) {
  int v = 0;
  for (; p >= 1; p -= (p & (-p))) v = max(v, AIB[p]);
  return v;
}
int main() {
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> A[i];
    int l = query(A[i]);
    l++;
    ANS = max(ANS, l);
    update(A[i], l);
  }
  cout << ANS << '\n';
  return 0;
}
