#include <bits/stdc++.h>
using namespace std;
int BIT[10000001];
int A[10000001], maxVal = 10000001;
int query(int x) {
  int ans = 0;
  while (x > 0) {
    ans = max(ans, BIT[x]);
    x -= (x & -x);
  }
  return ans;
}
void update(int x, int value) {
  while (x <= maxVal) {
    BIT[x] = max(BIT[x], value);
    x += (x & -x);
  }
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int temp = query(A[i]);
    ans = max(ans, temp + 1);
    update(A[i], temp + 1);
  }
  cout << ans << endl;
  return 0;
}
