#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const int MOD = 1000000007;
int T[5000009];
struct fenwick {
  int sum(int i) {
    int s = 0;
    for (; i > 0; i -= (i & -i)) {
      s = max(T[i], s);
    }
    return s;
  }
  void update(int i, int v) {
    for (; i < 1000009; i += (i & -i)) {
      T[i] = max(T[i], v);
    }
  }
};
int N;
vector<int> V;
map<int, int> MP;
map<int, int> RE;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    V.push_back(num);
  }
  vector<int> aux = V;
  fenwick F;
  sort(aux.begin(), aux.end());
  int k = 1;
  for (int i = 0; i < N; i++) {
    if (!MP.count(aux[i])) {
      MP[aux[i]] = k;
      RE[k] = aux[i];
      k++;
    }
  }
  int mm = 0;
  set<pair<int, int> > S;
  for (int i = 0; i < N; i++) {
    int num = MP[V[i]];
    int v = F.sum(num - 1);
    F.update(num, v + 1);
    mm = max(v + 1, mm);
  }
  cout << mm << endl;
  return 0;
}
